From 385a0ed7de64577b51844ce3bed9ada02e5a121e Mon Sep 17 00:00:00 2001 From: Kaity A Date: Thu, 29 Dec 2022 09:53:04 +0000 Subject: [PATCH] add antenna mark read functionality --- .../server/api/endpoints/antennas/markread.ts | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 packages/backend/src/server/api/endpoints/antennas/markread.ts diff --git a/packages/backend/src/server/api/endpoints/antennas/markread.ts b/packages/backend/src/server/api/endpoints/antennas/markread.ts new file mode 100644 index 0000000000..5ea3b0c600 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/antennas/markread.ts @@ -0,0 +1,45 @@ +import define from '../../define.js'; +import { Antennas, AntennaNotes } from '@/models/index.js'; +import { FindOptionsWhere } from 'typeorm'; +import { AntennaNote } from '@/models/entities/antenna-note.js'; + +export const meta = { + tags: ['antennas', 'account'], + + requireCredential: true, + + kind: 'write:account', + +} as const; + +export const paramDef = { + type: 'object', + properties: { + antennaId: { type: 'string', format: 'misskey:id' }, + }, + required: ['antennaId'], +} as const; + +// eslint-disable-next-line import/no-default-export +export default define(meta, paramDef, async (ps, me) => { + const antenna = await Antennas.findOneBy({ + userId: me.id, + id: ps.antennaId, + }); + + if (!antenna) { + return null + } + + await AntennaNotes.update({ + antennaId: antenna.id, + read: false, + }, { + read: true, + }) + + return true + +}); + +