Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
341
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
25
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
TransFem.org
Sharkey
Commits
0ef28037
Commit
0ef28037
authored
6 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
9c2f340c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/models/note.ts
+8
-3
8 additions, 3 deletions
src/models/note.ts
src/models/notification.ts
+27
-0
27 additions, 0 deletions
src/models/notification.ts
src/models/user.ts
+11
-0
11 additions, 0 deletions
src/models/user.ts
with
46 additions
and
3 deletions
src/models/note.ts
+
8
−
3
View file @
0ef28037
...
...
@@ -5,13 +5,13 @@ import db from '../db/mongodb';
import
{
IUser
,
pack
as
packUser
}
from
'
./user
'
;
import
{
pack
as
packApp
}
from
'
./app
'
;
import
{
pack
as
packChannel
}
from
'
./channel
'
;
import
Vote
,
{
deletePollVote
}
from
'
./poll-vote
'
;
import
Poll
Vote
,
{
deletePollVote
}
from
'
./poll-vote
'
;
import
Reaction
,
{
deleteNoteReaction
}
from
'
./note-reaction
'
;
import
{
pack
as
packFile
}
from
'
./drive-file
'
;
import
NoteWatching
,
{
deleteNoteWatching
}
from
'
./note-watching
'
;
import
NoteReaction
from
'
./note-reaction
'
;
import
Favorite
,
{
deleteFavorite
}
from
'
./favorite
'
;
import
PollVote
from
'
./poll-vote
'
;
import
Notification
,
{
deleteNotification
}
from
'
./notification
'
;
const
Note
=
db
.
get
<
INote
>
(
'
notes
'
);
...
...
@@ -123,6 +123,11 @@ export async function deleteNote(note: string | mongo.ObjectID | INote) {
await
Favorite
.
find
({
noteId
:
n
.
_id
})
).
map
(
x
=>
deleteFavorite
(
x
)));
// この投稿に対するNotificationをすべて削除
await
Promise
.
all
((
await
Notification
.
find
({
noteId
:
n
.
_id
})
).
map
(
x
=>
deleteNotification
(
x
)));
// このNoteを削除
await
Note
.
remove
({
_id
:
n
.
_id
...
...
@@ -258,7 +263,7 @@ export const pack = async (
// Poll
if
(
meId
&&
_note
.
poll
)
{
_note
.
poll
=
(
async
(
poll
)
=>
{
const
vote
=
await
Vote
const
vote
=
await
Poll
Vote
.
findOne
({
userId
:
meId
,
noteId
:
id
...
...
This diff is collapsed.
Click to expand it.
src/models/notification.ts
+
27
−
0
View file @
0ef28037
...
...
@@ -49,6 +49,33 @@ export interface INotification {
isRead
:
Boolean
;
}
/**
* Notificationを物理削除します
*/
export
async
function
deleteNotification
(
notification
:
string
|
mongo
.
ObjectID
|
INotification
)
{
let
n
:
INotification
;
// Populate
if
(
mongo
.
ObjectID
.
prototype
.
isPrototypeOf
(
notification
))
{
n
=
await
Notification
.
findOne
({
_id
:
notification
});
}
else
if
(
typeof
notification
===
'
string
'
)
{
n
=
await
Notification
.
findOne
({
_id
:
new
mongo
.
ObjectID
(
notification
)
});
}
else
{
n
=
notification
as
INotification
;
}
if
(
n
==
null
)
return
;
// このNotificationを削除
await
Notification
.
remove
({
_id
:
n
.
_id
});
}
/**
* Pack a notification for API response
*/
...
...
This diff is collapsed.
Click to expand it.
src/models/user.ts
+
11
−
0
View file @
0ef28037
...
...
@@ -19,6 +19,7 @@ import PollVote, { deletePollVote } from './poll-vote';
import
FollowingLog
,
{
deleteFollowingLog
}
from
'
./following-log
'
;
import
FollowedLog
,
{
deleteFollowedLog
}
from
'
./followed-log
'
;
import
SwSubscription
,
{
deleteSwSubscription
}
from
'
./sw-subscription
'
;
import
Notification
,
{
deleteNotification
}
from
'
./notification
'
;
const
User
=
db
.
get
<
IUser
>
(
'
users
'
);
...
...
@@ -246,6 +247,16 @@ export async function deleteUser(user: string | mongo.ObjectID | IUser) {
await
SwSubscription
.
find
({
userId
:
u
.
_id
})
).
map
(
x
=>
deleteSwSubscription
(
x
)));
// このユーザーのNotificationをすべて削除
await
Promise
.
all
((
await
Notification
.
find
({
notifieeId
:
u
.
_id
})
).
map
(
x
=>
deleteNotification
(
x
)));
// このユーザーが原因となったNotificationをすべて削除
await
Promise
.
all
((
await
Notification
.
find
({
notifierId
:
u
.
_id
})
).
map
(
x
=>
deleteNotification
(
x
)));
// このユーザーを削除
}
...
...
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