Skip to content

Commit

Permalink
投稿のウォッチ処理を削除
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Feb 23, 2022
1 parent 98eb2cf commit dadb690
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions src/services/note/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import renderAnnounce from '../../remote/activitypub/renderer/announce';
import { renderActivity } from '../../remote/activitypub/renderer';
import DriveFile, { IDriveFile } from '../../models/drive-file';
import { createNotification } from '../../services/create-notification';
import NoteWatching from '../../models/note-watching';
import watch from './watch';
import { parseBasic } from '../../mfm/parse';
import { IApp } from '../../models/app';
import resolveUser from '../../remote/resolve-user';
Expand Down Expand Up @@ -333,14 +331,6 @@ export default async (user: IUser, data: Option, silent = false) => {

// If has in reply to note
if (data.reply) {
// Fetch watchers
nmRelatedPromises.push(notifyToWatchersOfReplyee(data.reply, user, nm));

// この投稿をWatchする
if (isLocalUser(user) && user.settings.autoWatch !== false) {
watch(user._id, data.reply);
}

// 通知
if (isLocalUser(data.reply._user)) {
nm.push(data.reply.userId, 'reply');
Expand All @@ -360,14 +350,6 @@ export default async (user: IUser, data: Option, silent = false) => {
nm.push(data.renote.userId, type);
}

// Fetch watchers
nmRelatedPromises.push(notifyToWatchersOfRenotee(data.renote, user, nm, type));

// この投稿をWatchする
if (isLocalUser(user) && user.settings.autoWatch !== false) {
watch(user._id, data.renote);
}

// Publish event
if (!user._id.equals(data.renote.userId) && isLocalUser(data.renote._user)) {
publishMainStream(data.renote.userId, 'renote', noteObj);
Expand Down Expand Up @@ -587,36 +569,6 @@ function index(note: INote) {
}
}

async function notifyToWatchersOfRenotee(renote: INote, user: IUser, nm: NotificationManager, type: NotificationType) {
const watchers = await NoteWatching.find({
noteId: renote._id,
userId: { $ne: user._id }
}, {
fields: {
userId: true
}
});

for (const watcher of watchers) {
nm.push(watcher.userId, type);
}
}

async function notifyToWatchersOfReplyee(reply: INote, user: IUser, nm: NotificationManager) {
const watchers = await NoteWatching.find({
noteId: reply._id,
userId: { $ne: user._id }
}, {
fields: {
userId: true
}
});

for (const watcher of watchers) {
nm.push(watcher.userId, 'reply');
}
}

async function notifyExtended(note: INote, nm: NotificationManager) {
const text = note.text;
if (!text) return;
Expand Down

0 comments on commit dadb690

Please sign in to comment.