diff options
Diffstat (limited to 'server/lib/notifier/shared/abuse/abstract-new-abuse-message.ts')
-rw-r--r-- | server/lib/notifier/shared/abuse/abstract-new-abuse-message.ts | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/server/lib/notifier/shared/abuse/abstract-new-abuse-message.ts b/server/lib/notifier/shared/abuse/abstract-new-abuse-message.ts deleted file mode 100644 index 1dc1ccfc2..000000000 --- a/server/lib/notifier/shared/abuse/abstract-new-abuse-message.ts +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | import { WEBSERVER } from '@server/initializers/constants' | ||
2 | import { AccountModel } from '@server/models/account/account' | ||
3 | import { UserNotificationModel } from '@server/models/user/user-notification' | ||
4 | import { MAbuseFull, MAbuseMessage, MAccountDefault, MUserWithNotificationSetting, UserNotificationModelForApi } from '@server/types/models' | ||
5 | import { UserNotificationType } from '@shared/models' | ||
6 | import { AbstractNotification } from '../common/abstract-notification' | ||
7 | |||
8 | type NewAbuseMessagePayload = { | ||
9 | abuse: MAbuseFull | ||
10 | message: MAbuseMessage | ||
11 | } | ||
12 | |||
13 | export abstract class AbstractNewAbuseMessage extends AbstractNotification <NewAbuseMessagePayload> { | ||
14 | protected messageAccount: MAccountDefault | ||
15 | |||
16 | async loadMessageAccount () { | ||
17 | this.messageAccount = await AccountModel.load(this.message.accountId) | ||
18 | } | ||
19 | |||
20 | getSetting (user: MUserWithNotificationSetting) { | ||
21 | return user.NotificationSetting.abuseNewMessage | ||
22 | } | ||
23 | |||
24 | createNotification (user: MUserWithNotificationSetting) { | ||
25 | const notification = UserNotificationModel.build<UserNotificationModelForApi>({ | ||
26 | type: UserNotificationType.ABUSE_NEW_MESSAGE, | ||
27 | userId: user.id, | ||
28 | abuseId: this.abuse.id | ||
29 | }) | ||
30 | notification.Abuse = this.abuse | ||
31 | |||
32 | return notification | ||
33 | } | ||
34 | |||
35 | protected createEmailFor (to: string, target: 'moderator' | 'reporter') { | ||
36 | const text = 'New message on report #' + this.abuse.id | ||
37 | const abuseUrl = target === 'moderator' | ||
38 | ? WEBSERVER.URL + '/admin/moderation/abuses/list?search=%23' + this.abuse.id | ||
39 | : WEBSERVER.URL + '/my-account/abuses?search=%23' + this.abuse.id | ||
40 | |||
41 | const action = { | ||
42 | text: 'View report #' + this.abuse.id, | ||
43 | url: abuseUrl | ||
44 | } | ||
45 | |||
46 | return { | ||
47 | template: 'abuse-new-message', | ||
48 | to, | ||
49 | subject: text, | ||
50 | locals: { | ||
51 | abuseId: this.abuse.id, | ||
52 | abuseUrl: action.url, | ||
53 | messageAccountName: this.messageAccount.getDisplayName(), | ||
54 | messageText: this.message.message, | ||
55 | action | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | |||
60 | protected get abuse () { | ||
61 | return this.payload.abuse | ||
62 | } | ||
63 | |||
64 | protected get message () { | ||
65 | return this.payload.message | ||
66 | } | ||
67 | } | ||