Merge branch 'develop' of https://github.com/syuilo/misskey into develop

This commit is contained in:
syuilo 2019-03-14 15:19:09 +09:00
commit d762a6ce58
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
3 changed files with 26 additions and 4 deletions

View file

@ -1,3 +1,3 @@
import Logger from "../services/logger";
import Logger from '../services/logger';
export const remoteLogger = new Logger('remote', 'cyan');

View file

@ -1,7 +1,9 @@
import $ from 'cafy';
import ID, { transform } from '../../../../misc/cafy-id';
import define from '../../define';
import User from '../../../../models/user';
import User, { IUser } from '../../../../models/user';
import Following from '../../../../models/following';
import deleteFollowing from '../../../../services/following/delete';
export const meta = {
desc: {
@ -51,5 +53,25 @@ export default define(meta, async (ps) => {
}
});
unFollowAll(user);
return;
});
async function unFollowAll(follower: IUser) {
const followings = await Following.find({
followerId: follower._id
});
for (const following of followings) {
const followee = await User.findOne({
_id: following.followeeId
});
if (followee == null) {
throw `Cant find followee ${following.followeeId}`;
}
await deleteFollowing(follower, followee, true);
}
}

View file

@ -13,7 +13,7 @@ import instanceChart from '../../services/chart/instance';
const logger = new Logger('following/delete');
export default async function(follower: IUser, followee: IUser) {
export default async function(follower: IUser, followee: IUser, silent = false) {
const following = await Following.findOne({
followerId: follower._id,
followeeId: followee._id
@ -71,7 +71,7 @@ export default async function(follower: IUser, followee: IUser) {
perUserFollowingChart.update(follower, followee, false);
// Publish unfollow event
if (isLocalUser(follower)) {
if (!silent && isLocalUser(follower)) {
packUser(followee, follower, {
detail: true
}).then(packed => publishMainStream(follower._id, 'unfollow', packed));