summaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-03-28 19:52:41 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-03-28 19:52:41 +0900
commitf014a79f8dbb101a80d638d025a27bbb5ea02575 (patch)
treecc8af5c152e6470cddf1f34d083e2e0e222e7610 /src/services
parentMerge branch 'develop' (diff)
parent12.27.0 (diff)
downloadmisskey-f014a79f8dbb101a80d638d025a27bbb5ea02575.tar.gz
misskey-f014a79f8dbb101a80d638d025a27bbb5ea02575.tar.bz2
misskey-f014a79f8dbb101a80d638d025a27bbb5ea02575.zip
Merge branch 'develop'
Diffstat (limited to 'src/services')
-rw-r--r--src/services/create-notification.ts34
-rw-r--r--src/services/following/create.ts8
-rw-r--r--src/services/following/requests/create.ts3
-rw-r--r--src/services/logger.ts1
-rw-r--r--src/services/note/create.ts3
-rw-r--r--src/services/note/polls/vote.ts6
-rw-r--r--src/services/note/reaction/create.ts6
7 files changed, 26 insertions, 35 deletions
diff --git a/src/services/create-notification.ts b/src/services/create-notification.ts
index c5c6e7144b..7fc8bfaf53 100644
--- a/src/services/create-notification.ts
+++ b/src/services/create-notification.ts
@@ -3,46 +3,26 @@ import pushSw from './push-notification';
import { Notifications, Mutings } from '../models';
import { genId } from '../misc/gen-id';
import { User } from '../models/entities/user';
-import { Note } from '../models/entities/note';
import { Notification } from '../models/entities/notification';
-import { FollowRequest } from '../models/entities/follow-request';
-import { UserGroupInvitation } from '../models/entities/user-group-invitation';
export async function createNotification(
notifieeId: User['id'],
- notifierId: User['id'],
type: Notification['type'],
- content?: {
- noteId?: Note['id'];
- reaction?: string;
- choice?: number;
- followRequestId?: FollowRequest['id'];
- userGroupInvitationId?: UserGroupInvitation['id'];
- }
+ data: Partial<Notification>
) {
- if (notifieeId === notifierId) {
+ if (data.notifierId && (notifieeId === data.notifierId)) {
return null;
}
- const data = {
+ // Create notification
+ const notification = await Notifications.save({
id: genId(),
createdAt: new Date(),
notifieeId: notifieeId,
- notifierId: notifierId,
type: type,
isRead: false,
- } as Partial<Notification>;
-
- if (content) {
- if (content.noteId) data.noteId = content.noteId;
- if (content.reaction) data.reaction = content.reaction;
- if (content.choice) data.choice = content.choice;
- if (content.followRequestId) data.followRequestId = content.followRequestId;
- if (content.userGroupInvitationId) data.userGroupInvitationId = content.userGroupInvitationId;
- }
-
- // Create notification
- const notification = await Notifications.save(data);
+ ...data
+ } as Partial<Notification>);
const packed = await Notifications.pack(notification);
@@ -58,7 +38,7 @@ export async function createNotification(
const mutings = await Mutings.find({
muterId: notifieeId
});
- if (mutings.map(m => m.muteeId).includes(notifierId)) {
+ if (data.notifierId && mutings.map(m => m.muteeId).includes(data.notifierId)) {
return;
}
//#endregion
diff --git a/src/services/following/create.ts b/src/services/following/create.ts
index ce352ffbc1..c5f130f49f 100644
--- a/src/services/following/create.ts
+++ b/src/services/following/create.ts
@@ -57,7 +57,9 @@ export async function insertFollowingDoc(followee: User, follower: User) {
});
// 通知を作成
- createNotification(follower.id, followee.id, 'followRequestAccepted');
+ createNotification(follower.id, 'followRequestAccepted', {
+ notifierId: followee.id,
+ });
}
if (alreadyFollowed) return;
@@ -95,7 +97,9 @@ export async function insertFollowingDoc(followee: User, follower: User) {
Users.pack(follower, followee).then(packed => publishMainStream(followee.id, 'followed', packed)),
// 通知を作成
- createNotification(followee.id, follower.id, 'follow');
+ createNotification(followee.id, 'follow', {
+ notifierId: follower.id
+ });
}
}
diff --git a/src/services/following/requests/create.ts b/src/services/following/requests/create.ts
index 1c6bac0fbe..deaeedb9a8 100644
--- a/src/services/following/requests/create.ts
+++ b/src/services/following/requests/create.ts
@@ -50,7 +50,8 @@ export default async function(follower: User, followee: User, requestId?: string
}).then(packed => publishMainStream(followee.id, 'meUpdated', packed));
// 通知を作成
- createNotification(followee.id, follower.id, 'receiveFollowRequest', {
+ createNotification(followee.id, 'receiveFollowRequest', {
+ notifierId: follower.id,
followRequestId: followRequest.id
});
}
diff --git a/src/services/logger.ts b/src/services/logger.ts
index 0e26e80ed6..eb2b257dde 100644
--- a/src/services/logger.ts
+++ b/src/services/logger.ts
@@ -54,6 +54,7 @@ export default class Logger {
private log(level: Level, message: string, data?: Record<string, any> | null, important = false, subDomains: Domain[] = [], store = true): void {
if (program.quiet) return;
if (!this.store) store = false;
+ if (level === 'debug') store = false;
if (this.parentLogger) {
this.parentLogger.log(level, message, data, important, [this.domain].concat(subDomains), store);
diff --git a/src/services/note/create.ts b/src/services/note/create.ts
index 50586e8bc7..60a5a5e69d 100644
--- a/src/services/note/create.ts
+++ b/src/services/note/create.ts
@@ -78,7 +78,8 @@ class NotificationManager {
// 通知される側のユーザーが通知する側のユーザーをミュートしていない限りは通知する
if (!mentioneesMutedUserIds.includes(this.notifier.id)) {
- createNotification(x.target, this.notifier.id, x.reason, {
+ createNotification(x.target, x.reason, {
+ notifierId: this.notifier.id,
noteId: this.note.id
});
}
diff --git a/src/services/note/polls/vote.ts b/src/services/note/polls/vote.ts
index aee52ba10d..7350c813af 100644
--- a/src/services/note/polls/vote.ts
+++ b/src/services/note/polls/vote.ts
@@ -48,7 +48,8 @@ export default async function(user: User, note: Note, choice: number) {
});
// Notify
- createNotification(note.userId, user.id, 'pollVote', {
+ createNotification(note.userId, 'pollVote', {
+ notifierId: user.id,
noteId: note.id,
choice: choice
});
@@ -60,7 +61,8 @@ export default async function(user: User, note: Note, choice: number) {
})
.then(watchers => {
for (const watcher of watchers) {
- createNotification(watcher.userId, user.id, 'pollVote', {
+ createNotification(watcher.userId, 'pollVote', {
+ notifierId: user.id,
noteId: note.id,
choice: choice
});
diff --git a/src/services/note/reaction/create.ts b/src/services/note/reaction/create.ts
index 166c4e1f81..72750affe0 100644
--- a/src/services/note/reaction/create.ts
+++ b/src/services/note/reaction/create.ts
@@ -66,7 +66,8 @@ export default async (user: User, note: Note, reaction?: string) => {
// リアクションされたユーザーがローカルユーザーなら通知を作成
if (note.userHost === null) {
- createNotification(note.userId, user.id, 'reaction', {
+ createNotification(note.userId, 'reaction', {
+ notifierId: user.id,
noteId: note.id,
reaction: reaction
});
@@ -78,7 +79,8 @@ export default async (user: User, note: Note, reaction?: string) => {
userId: Not(user.id)
}).then(watchers => {
for (const watcher of watchers) {
- createNotification(watcher.userId, user.id, 'reaction', {
+ createNotification(watcher.userId, 'reaction', {
+ notifierId: user.id,
noteId: note.id,
reaction: reaction
});