Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec(notes/create): 投稿されたnoteを返さないオプションを追加 #879

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/backend/src/server/api/endpoints/notes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const meta = {

res: {
type: 'object',
optional: false, nullable: false,
optional: true, nullable: false,
properties: {
createdNote: {
type: 'object',
Expand Down Expand Up @@ -207,6 +207,7 @@ export const paramDef = {
},
required: ['choices'],
},
noCreatedNote: { type: 'boolean', default: false },
},
// (re)note with text, files and poll are optional
if: {
Expand Down Expand Up @@ -281,7 +282,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const note = await this.notesRepository.findOneBy({ id: idempotent });
if (note) {
logger.info('The request has already been processed.', { noteId: note.id });
return { createdNote: await this.noteEntityService.pack(note, me) };
if (ps.noCreatedNote) return;
else return { createdNote: await this.noteEntityService.pack(note, me) };
}
}

Expand Down Expand Up @@ -453,7 +455,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
await this.redisForTimelines.set(`note:idempotent:${me.id}:${hash}`, note.id, 'EX', 60);

logger.info('Successfully created a note.', { noteId: note.id });
return {
if (ps.noCreatedNote) return;
else return {
createdNote: await this.noteEntityService.pack(note, me),
};
} catch (err) {
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/server/web/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ window.onload = async () => {

document.getElementById('submit').addEventListener('click', () => {
api('notes/create', {
text: document.getElementById('text').value
text: document.getElementById('text').value,
noCreatedNote: true,
}).then(() => {
location.reload();
});
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/components/MkPostForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ async function post(ev?: MouseEvent) {
visibility: visibility.value,
visibleUserIds: visibility.value === 'specified' ? visibleUsers.value.map(u => u.id) : undefined,
reactionAcceptance: reactionAcceptance.value,
noCreatedNote: true,
};

if (withHashtags.value && hashtags.value && hashtags.value.trim() !== '') {
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/pages/reversi/game.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function start(_game: Misskey.entities.ReversiGameDetailed) {
misskeyApi('notes/create', {
text: i18n.ts._reversi.iStartedAGame + '\n' + location.href,
visibility: 'home',
noCreatedNote: true,
});
}

Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/src/scripts/get-note-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ export function getRenoteMenu(props: {
misskeyApi('notes/create', {
renoteId: appearNote.id,
channelId: appearNote.channelId,
noCreatedNote: true,
}).then(() => {
os.toast(i18n.ts.renoted);
});
Expand Down Expand Up @@ -589,6 +590,7 @@ export function getRenoteMenu(props: {
localOnly,
visibility,
renoteId: appearNote.id,
noCreatedNote: true,
}).then(() => {
os.toast(i18n.ts.renoted);
});
Expand Down Expand Up @@ -630,6 +632,7 @@ export function getRenoteMenu(props: {
misskeyApi('notes/create', {
renoteId: appearNote.id,
channelId: channel.id,
noCreatedNote: true,
}).then(() => {
os.toast(i18n.tsx.renotedToX({ name: channel.name }));
});
Expand Down
6 changes: 6 additions & 0 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23333,6 +23333,8 @@ export type operations = {
expiresAt?: number | null;
expiredAfter?: number | null;
}) | null;
/** @default false */
noCreatedNote?: boolean;
};
};
};
Expand All @@ -23345,6 +23347,10 @@ export type operations = {
};
};
};
/** @description OK (without any results) */
204: {
content: never;
};
/** @description Client error */
400: {
content: {
Expand Down
2 changes: 1 addition & 1 deletion packages/sw/src/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ globalThis.addEventListener('notificationclick', (ev: ServiceWorkerGlobalScopeEv
if ('note' in data.body) client = await swos.openPost({ reply: data.body.note }, loginId);
break;
case 'renote':
if ('note' in data.body) await swos.api('notes/create', loginId, { renoteId: data.body.note.id });
if ('note' in data.body) await swos.api('notes/create', loginId, { renoteId: data.body.note.id, noCreatedNote: true });
break;
case 'accept':
switch (data.body.type) {
Expand Down
Loading