summaryrefslogtreecommitdiff
path: root/src/remote/activitypub/renderer/vote.ts
blob: ff038070f77bdb9fd9d45cc6ed7291864d48c9c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import config from '@/config/index';
import { Note } from '@/models/entities/note';
import { IRemoteUser, User } from '@/models/entities/user';
import { PollVote } from '@/models/entities/poll-vote';
import { Poll } from '@/models/entities/poll';

export default async function renderVote(user: { id: User['id'] }, vote: PollVote, note: Note, poll: Poll, pollOwner: IRemoteUser): Promise<any> {
	return {
		id: `${config.url}/users/${user.id}#votes/${vote.id}/activity`,
		actor: `${config.url}/users/${user.id}`,
		type: 'Create',
		to: [pollOwner.uri],
		published: new Date().toISOString(),
		object: {
			id: `${config.url}/users/${user.id}#votes/${vote.id}`,
			type: 'Note',
			attributedTo: `${config.url}/users/${user.id}`,
			to: [pollOwner.uri],
			inReplyTo: note.uri,
			name: poll.choices[vote.choice]
		}
	};
}