mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 12:33:08 +02:00
wip
This commit is contained in:
parent
35115607bc
commit
bae44b4708
5 changed files with 25 additions and 1 deletions
|
@ -62,6 +62,11 @@ type IUserBase = {
|
||||||
*/
|
*/
|
||||||
isLocked: boolean;
|
isLocked: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* このアカウントに届いているフォローリクエストの数
|
||||||
|
*/
|
||||||
|
pendingReceivedFollowRequestsCount: number;
|
||||||
|
|
||||||
host: string;
|
host: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||||
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user';
|
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user';
|
||||||
import event from '../../../../publishers/stream';
|
import event from '../../../../publishers/stream';
|
||||||
import DriveFile from '../../../../models/drive-file';
|
import DriveFile from '../../../../models/drive-file';
|
||||||
|
import acceptAllFollowRequests from '../../../../services/user/accept-all-follow-requests';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update myself
|
* Update myself
|
||||||
|
|
|
@ -28,6 +28,12 @@ export default async function(follower: IUser, followee: IUser) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
User.update({ _id: followee._id }, {
|
||||||
|
$inc: {
|
||||||
|
pendingReceivedFollowRequestsCount: 1
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Publish reciveRequest event
|
// Publish reciveRequest event
|
||||||
if (isLocalUser(followee)) {
|
if (isLocalUser(followee)) {
|
||||||
packUser(follower, followee).then(packed => event(followee._id, 'reciveRequest', packed)),
|
packUser(follower, followee).then(packed => event(followee._id, 'reciveRequest', packed)),
|
||||||
|
|
|
@ -15,4 +15,10 @@ export default async function(user: IUser) {
|
||||||
const follower = await User.findOne({ _id: request.followerId });
|
const follower = await User.findOne({ _id: request.followerId });
|
||||||
accept(user, follower);
|
accept(user, follower);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
User.update({ _id: user._id }, {
|
||||||
|
$set: {
|
||||||
|
pendingReceivedFollowRequestsCount: 0
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,14 @@ export default async function(followee: IUser, follower: IUser) {
|
||||||
deliver(followee as ILocalUser, content, follower.inbox);
|
deliver(followee as ILocalUser, content, follower.inbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
FollowRequest.remove({
|
await FollowRequest.remove({
|
||||||
followeeId: followee._id,
|
followeeId: followee._id,
|
||||||
followerId: follower._id
|
followerId: follower._id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
User.update({ _id: followee._id }, {
|
||||||
|
$inc: {
|
||||||
|
pendingReceivedFollowRequestsCount: -1
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue