Compare commits
2 commits
78359daac6
...
86565cd25b
Author | SHA1 | Date | |
---|---|---|---|
86565cd25b | |||
24f6177b94 |
4 changed files with 57 additions and 1 deletions
|
@ -7,7 +7,7 @@ import { updatePerson } from '@/remote/activitypub/models/person.js';
|
|||
import { update as updateNote } from '@/remote/activitypub/kernel/update/note.js';
|
||||
|
||||
/**
|
||||
* Updateアクティビティを捌きます
|
||||
* Handle Update activity
|
||||
*/
|
||||
export default async (actor: IRemoteUser, activity: IUpdate, resolver: Resolver): Promise<string> => {
|
||||
if ('actor' in activity && actor.uri !== activity.actor) {
|
||||
|
|
|
@ -221,6 +221,7 @@ import * as ep___notes_hybridTimeline from './endpoints/notes/hybrid-timeline.js
|
|||
import * as ep___notes_localTimeline from './endpoints/notes/local-timeline.js';
|
||||
import * as ep___notes_mentions from './endpoints/notes/mentions.js';
|
||||
import * as ep___notes_polls_vote from './endpoints/notes/polls/vote.js';
|
||||
import * as ep___notes_polls_update from './endpoints/notes/polls/update.js';
|
||||
import * as ep___notes_reactions from './endpoints/notes/reactions.js';
|
||||
import * as ep___notes_reactions_create from './endpoints/notes/reactions/create.js';
|
||||
import * as ep___notes_reactions_delete from './endpoints/notes/reactions/delete.js';
|
||||
|
@ -515,6 +516,7 @@ const eps = [
|
|||
['notes/local-timeline', ep___notes_localTimeline],
|
||||
['notes/mentions', ep___notes_mentions],
|
||||
['notes/polls/vote', ep___notes_polls_vote],
|
||||
['notes/polls/update', ep___notes_polls_update],
|
||||
['notes/reactions', ep___notes_reactions],
|
||||
['notes/reactions/create', ep___notes_reactions_create],
|
||||
['notes/reactions/delete', ep___notes_reactions_delete],
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
import { getNote } from '@/server/api/common/getters.js';
|
||||
import { ApiError } from '@/server/api/error.js';
|
||||
import define from '@/server/api/define.js';
|
||||
import { Resolver } from '@/remote/activitypub/resolver.js';
|
||||
import { updateQuestion } from '@/remote/activitypub/models/question.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['notes'],
|
||||
|
||||
description: 'Fetches an updated number of votes for a poll attached to a remote note.',
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'write:votes',
|
||||
|
||||
errors: ['NO_SUCH_NOTE'],
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
noteId: { type: 'string', format: 'misskey:id' },
|
||||
},
|
||||
required: ['noteId'],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
// Get votee
|
||||
const note = await getNote(ps.noteId, user).catch(err => {
|
||||
if (err.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError('NO_SUCH_NOTE');
|
||||
throw err;
|
||||
});
|
||||
|
||||
if (!note.hasPoll) {
|
||||
throw new ApiError('NO_SUCH_NOTE', 'The note exists but does not have a poll attached.');
|
||||
}
|
||||
|
||||
if (note.uri == null) {
|
||||
throw new ApiError('NO_SUCH_NOTE', 'Can only update polls of remote notes.');
|
||||
}
|
||||
|
||||
await updateQuestion(note.uri, new Resolver());
|
||||
});
|
|
@ -13,6 +13,8 @@
|
|||
<p v-if="!readOnly">
|
||||
<span>{{ i18n.t('_poll.totalVotes', { n: total }) }}</span>
|
||||
<span> · </span>
|
||||
<a @click="update()">{{ i18n.ts.reload }}</a>
|
||||
<span> · </span>
|
||||
<a v-if="!closed && !isVoted" @click="showResult = !showResult">{{ showResult ? i18n.ts._poll.vote : i18n.ts._poll.showResult }}</a>
|
||||
<span v-if="isVoted">{{ i18n.ts._poll.voted }}</span>
|
||||
<span v-else-if="closed">{{ i18n.ts._poll.closed }}</span>
|
||||
|
@ -84,6 +86,14 @@ const vote = async (id) => {
|
|||
});
|
||||
if (!showResult.value) showResult.value = !props.note.poll.multiple;
|
||||
};
|
||||
|
||||
const update = async () => {
|
||||
pleaseLoginOrRemote(urlForNote(props.note));
|
||||
|
||||
await os.apiWithDialog('notes/polls/update', {
|
||||
noteId: props.note.id,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
Loading…
Add table
Reference in a new issue