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
Essem
Sharkey
Commits
03c824f8
Commit
03c824f8
authored
6 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
9e74a3b8
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/user-list.ts
+40
-0
40 additions, 0 deletions
src/models/user-list.ts
src/models/user.ts
+15
-0
15 additions, 0 deletions
src/models/user.ts
with
55 additions
and
0 deletions
src/models/user-list.ts
0 → 100644
+
40
−
0
View file @
03c824f8
import
*
as
mongo
from
'
mongodb
'
;
import
db
from
'
../db/mongodb
'
;
const
UserList
=
db
.
get
<
IUserList
>
(
'
userList
'
);
export
default
UserList
;
export
interface
IUserList
{
_id
:
mongo
.
ObjectID
;
createdAt
:
Date
;
title
:
string
;
userId
:
mongo
.
ObjectID
;
userIds
:
mongo
.
ObjectID
[];
}
/**
* UserListを物理削除します
*/
export
async
function
deleteUserList
(
userList
:
string
|
mongo
.
ObjectID
|
IUserList
)
{
let
u
:
IUserList
;
// Populate
if
(
mongo
.
ObjectID
.
prototype
.
isPrototypeOf
(
userList
))
{
u
=
await
UserList
.
findOne
({
_id
:
userList
});
}
else
if
(
typeof
userList
===
'
string
'
)
{
u
=
await
UserList
.
findOne
({
_id
:
new
mongo
.
ObjectID
(
userList
)
});
}
else
{
u
=
userList
as
IUserList
;
}
if
(
u
==
null
)
return
;
// このUserListを削除
await
UserList
.
remove
({
_id
:
u
.
_id
});
}
This diff is collapsed.
Click to expand it.
src/models/user.ts
+
15
−
0
View file @
03c824f8
...
...
@@ -20,6 +20,7 @@ import FollowingLog, { deleteFollowingLog } from './following-log';
import
FollowedLog
,
{
deleteFollowedLog
}
from
'
./followed-log
'
;
import
SwSubscription
,
{
deleteSwSubscription
}
from
'
./sw-subscription
'
;
import
Notification
,
{
deleteNotification
}
from
'
./notification
'
;
import
UserList
,
{
deleteUserList
}
from
'
./user-list
'
;
const
User
=
db
.
get
<
IUser
>
(
'
users
'
);
...
...
@@ -260,6 +261,20 @@ export async function deleteUser(user: string | mongo.ObjectID | IUser) {
await
Notification
.
find
({
notifierId
:
u
.
_id
})
).
map
(
x
=>
deleteNotification
(
x
)));
// このユーザーのUserListをすべて削除
await
Promise
.
all
((
await
UserList
.
find
({
userId
:
u
.
_id
})
).
map
(
x
=>
deleteUserList
(
x
)));
// このユーザーの入っているすべてのUserListからこのユーザーを削除
await
Promise
.
all
((
await
UserList
.
find
({
userIds
:
u
.
_id
})
).
map
(
x
=>
UserList
.
update
({
_id
:
x
.
_id
},
{
$pull
:
{
userIds
:
u
.
_id
}
})
));
// このユーザーを削除
await
User
.
remove
({
_id
:
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