Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
9599a312
Commit
9599a312
authored
6 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
9fdb1259
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/models/follow-requests.ts
+50
-0
50 additions, 0 deletions
src/models/follow-requests.ts
src/models/user.ts
+21
-0
21 additions, 0 deletions
src/models/user.ts
with
71 additions
and
0 deletions
src/models/follow-requests.ts
0 → 100644
+
50
−
0
View file @
9599a312
import
*
as
mongo
from
'
mongodb
'
;
import
db
from
'
../db/mongodb
'
;
const
FollowRequest
=
db
.
get
<
IFollowRequest
>
(
'
followRequests
'
);
FollowRequest
.
createIndex
([
'
followerId
'
,
'
followeeId
'
],
{
unique
:
true
});
export
default
FollowRequest
;
export
type
IFollowRequest
=
{
_id
:
mongo
.
ObjectID
;
createdAt
:
Date
;
followeeId
:
mongo
.
ObjectID
;
followerId
:
mongo
.
ObjectID
;
// 非正規化
_followee
:
{
host
:
string
;
inbox
?:
string
;
},
_follower
:
{
host
:
string
;
inbox
?:
string
;
}
};
/**
* FollowRequestを物理削除します
*/
export
async
function
deleteFollowRequest
(
followRequest
:
string
|
mongo
.
ObjectID
|
IFollowRequest
)
{
let
f
:
IFollowRequest
;
// Populate
if
(
mongo
.
ObjectID
.
prototype
.
isPrototypeOf
(
followRequest
))
{
f
=
await
FollowRequest
.
findOne
({
_id
:
followRequest
});
}
else
if
(
typeof
followRequest
===
'
string
'
)
{
f
=
await
FollowRequest
.
findOne
({
_id
:
new
mongo
.
ObjectID
(
followRequest
)
});
}
else
{
f
=
followRequest
as
IFollowRequest
;
}
if
(
f
==
null
)
return
;
// このFollowingを削除
await
FollowRequest
.
remove
({
_id
:
f
.
_id
});
}
This diff is collapsed.
Click to expand it.
src/models/user.ts
+
21
−
0
View file @
9599a312
...
...
@@ -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-requests
'
;
const
User
=
db
.
get
<
IUser
>
(
'
users
'
);
...
...
@@ -50,7 +51,17 @@ type IUserBase = {
data
:
any
;
description
:
string
;
pinnedNoteId
:
mongo
.
ObjectID
;
/**
* 凍結されているか否か
*/
isSuspended
:
boolean
;
/**
* 鍵アカウントか否か
*/
isLocked
:
boolean
;
host
:
string
;
};
...
...
@@ -240,6 +251,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
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment