Revert "Send Update"

This reverts commit 171b046de5.
This commit is contained in:
mei23 2019-01-21 04:55:02 +09:00
parent 1dbc9f6bd7
commit 476bfbe24e
2 changed files with 1 additions and 38 deletions

View File

@ -7,7 +7,6 @@ import { publishNoteStream } from '../../../../../stream';
import notify from '../../../../../notify';
import define from '../../../define';
import createNote from '../../../../../services/note/create';
import { publishVoteToFollowers } from '../../../../../services/note/polls/vote';
export const meta = {
desc: {
@ -125,6 +124,4 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
reply: note,
});
}
publishVoteToFollowers(user, note);
}));

View File

@ -5,12 +5,7 @@ import watch from '../../../services/note/watch';
import { publishNoteStream } from '../../../stream';
import notify from '../../../notify';
import createNote from '../../../services/note/create';
import { isLocalUser, IUser, isRemoteUser } from '../../../models/user';
import Following from '../../../models/following';
import packAp from '../../../remote/activitypub/renderer';
import { deliver } from '../../../queue';
import renderUpdate from '../../../remote/activitypub/renderer/update';
import renderQuestion from '../../../remote/activitypub/renderer/question';
import { isLocalUser, IUser } from '../../../models/user';
export default (user: IUser, note: INote, choice: number) => new Promise(async (res, rej) => {
if (!note.poll.choices.some(x => x.id == choice)) return rej('invalid choice param');
@ -89,33 +84,4 @@ export default (user: IUser, note: INote, choice: number) => new Promise(async (
reply: note,
});
}
publishVoteToFollowers(user, note);
});
export async function publishVoteToFollowers(user: IUser, note: INote) {
const followers = await Following.find({
followeeId: user._id
});
const queue: string[] = [];
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーならUpdateを配信
if (isLocalUser(user)) {
for (const following of followers) {
const follower = following._follower;
if (isRemoteUser(follower)) {
const inbox = follower.sharedInbox || follower.inbox;
if (!queue.includes(inbox)) queue.push(inbox);
}
}
if (queue.length > 0) {
const content = packAp(renderUpdate(await renderQuestion(user, note), user));
for (const inbox of queue) {
deliver(user, content, inbox);
}
}
}
}