parent
1dbc9f6bd7
commit
476bfbe24e
|
@ -7,7 +7,6 @@ import { publishNoteStream } from '../../../../../stream';
|
||||||
import notify from '../../../../../notify';
|
import notify from '../../../../../notify';
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import createNote from '../../../../../services/note/create';
|
import createNote from '../../../../../services/note/create';
|
||||||
import { publishVoteToFollowers } from '../../../../../services/note/polls/vote';
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -125,6 +124,4 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
reply: note,
|
reply: note,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
publishVoteToFollowers(user, note);
|
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -5,12 +5,7 @@ import watch from '../../../services/note/watch';
|
||||||
import { publishNoteStream } from '../../../stream';
|
import { publishNoteStream } from '../../../stream';
|
||||||
import notify from '../../../notify';
|
import notify from '../../../notify';
|
||||||
import createNote from '../../../services/note/create';
|
import createNote from '../../../services/note/create';
|
||||||
import { isLocalUser, IUser, isRemoteUser } from '../../../models/user';
|
import { isLocalUser, IUser } 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';
|
|
||||||
|
|
||||||
export default (user: IUser, note: INote, choice: number) => new Promise(async (res, rej) => {
|
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');
|
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,
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue