diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2018-06-02 16:28:08 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-02 16:28:08 +0900 |
| commit | e25e1d88d60c4d427635e51609a6ecbfe7b6049b (patch) | |
| tree | b3b9890e83527d0d257c819a2c61981516945e21 /src/models/user.ts | |
| parent | Merge pull request #1672 from Angristan/patch-1 (diff) | |
| parent | wip (diff) | |
| download | misskey-e25e1d88d60c4d427635e51609a6ecbfe7b6049b.tar.gz misskey-e25e1d88d60c4d427635e51609a6ecbfe7b6049b.tar.bz2 misskey-e25e1d88d60c4d427635e51609a6ecbfe7b6049b.zip | |
Merge pull request #1671 from syuilo/locked-account
Locked account
Diffstat (limited to 'src/models/user.ts')
| -rw-r--r-- | src/models/user.ts | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/models/user.ts b/src/models/user.ts index 11eafe05ea..0e06512dae 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -22,6 +22,7 @@ import FollowedLog, { deleteFollowedLog } from './followed-log'; import SwSubscription, { deleteSwSubscription } from './sw-subscription'; import Notification, { deleteNotification } from './notification'; import UserList, { deleteUserList } from './user-list'; +import FollowRequest, { deleteFollowRequest } from './follow-request'; const User = db.get<IUser>('users'); @@ -50,7 +51,22 @@ type IUserBase = { data: any; description: string; pinnedNoteId: mongo.ObjectID; + + /** + * 凍結されているか否か + */ isSuspended: boolean; + + /** + * 鍵アカウントか否か + */ + isLocked: boolean; + + /** + * このアカウントに届いているフォローリクエストの数 + */ + pendingReceivedFollowRequestsCount: number; + host: string; }; @@ -240,6 +256,16 @@ export async function deleteUser(user: string | mongo.ObjectID | IUser) { await Following.find({ followeeId: u._id }) ).map(x => deleteFollowing(x))); + // このユーザーのFollowRequestをすべて削除 + await Promise.all(( + await FollowRequest.find({ followerId: u._id }) + ).map(x => deleteFollowRequest(x))); + + // このユーザーへのFollowRequestをすべて削除 + await Promise.all(( + await FollowRequest.find({ followeeId: u._id }) + ).map(x => deleteFollowRequest(x))); + // このユーザーのFollowingLogをすべて削除 await Promise.all(( await FollowingLog.find({ userId: u._id }) @@ -395,7 +421,7 @@ export const pack = ( } if (meId && !meId.equals(_user.id)) { - const [following1, following2, mute] = await Promise.all([ + const [following1, following2, followReq1, followReq2, mute] = await Promise.all([ Following.findOne({ followerId: meId, followeeId: _user.id @@ -404,6 +430,14 @@ export const pack = ( followerId: _user.id, followeeId: meId }), + _user.isLocked ? FollowRequest.findOne({ + followerId: meId, + followeeId: _user.id + }) : Promise.resolve(null), + FollowRequest.findOne({ + followerId: _user.id, + followeeId: meId + }), Mute.findOne({ muterId: meId, muteeId: _user.id @@ -414,6 +448,9 @@ export const pack = ( _user.isFollowing = following1 !== null; _user.isStalking = following1 && following1.stalk; + _user.hasPendingFollowRequestFromYou = followReq1 !== null; + _user.hasPendingFollowRequestToYou = followReq2 !== null; + // Whether the user is followed _user.isFollowed = following2 !== null; |