forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dbに投稿内容を保存するようにした Signed-off-by: mattyatea <mattyacocacora0@gmail.com>
- Loading branch information
Showing
15 changed files
with
238 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export class Schedulenote1699437894737 { | ||
name = 'Schedulenote1699437894737' | ||
|
||
async up(queryRunner) { | ||
await queryRunner.query(`CREATE TABLE "note_schedule" ("id" character varying(32) NOT NULL, "note" jsonb NOT NULL, "userId" character varying(260) NOT NULL, "expiresAt" TIMESTAMP WITH TIME ZONE NOT NULL, CONSTRAINT "PK_3a1ae2db41988f4994268218436" PRIMARY KEY ("id"))`); | ||
await queryRunner.query(`CREATE INDEX "IDX_e798958c40009bf0cdef4f28b5" ON "note_schedule" ("userId") `); | ||
} | ||
|
||
async down(queryRunner) { | ||
await queryRunner.query(`DROP TABLE "note_schedule"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/backend/src/server/api/endpoints/notes/delete-schedule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and other misskey contributors | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import ms from 'ms'; | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import type { NoteScheduleRepository } from '@/models/_.js'; | ||
import { Endpoint } from '@/server/api/endpoint-base.js'; | ||
import { DI } from '@/di-symbols.js'; | ||
|
||
export const meta = { | ||
tags: ['notes'], | ||
|
||
requireCredential: true, | ||
|
||
limit: { | ||
duration: ms('1hour'), | ||
max: 300, | ||
}, | ||
|
||
errors: { | ||
noSuchNote: { | ||
message: 'No such note.', | ||
code: 'NO_SUCH_NOTE', | ||
id: '490be23f-8c1f-4796-819f-94cb4f9d1630', | ||
}, | ||
}, | ||
} as const; | ||
|
||
export const paramDef = { | ||
type: 'object', | ||
properties: { | ||
noteId: { type: 'string', format: 'misskey:id' }, | ||
}, | ||
required: ['noteId'], | ||
} as const; | ||
|
||
@Injectable() | ||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export | ||
constructor( | ||
@Inject(DI.noteScheduleRepository) | ||
private noteScheduleRepository: NoteScheduleRepository, | ||
) { | ||
super(meta, paramDef, async (ps, me) => { | ||
await this.noteScheduleRepository.delete({ id: ps.noteId }); | ||
}); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
packages/backend/src/server/api/endpoints/notes/list-schedule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and other misskey contributors | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import ms from 'ms'; | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { Endpoint } from '@/server/api/endpoint-base.js'; | ||
import { DI } from '@/di-symbols.js'; | ||
import type { NoteScheduleRepository } from '@/models/_.js'; | ||
import { UserEntityService } from '@/core/entities/UserEntityService.js'; | ||
|
||
export const meta = { | ||
tags: ['notes'], | ||
|
||
requireCredential: true, | ||
res: { | ||
type: 'array', | ||
optional: false, nullable: false, | ||
items: { | ||
type: 'object', | ||
optional: false, nullable: false, | ||
ref: 'Note', | ||
}, | ||
}, | ||
limit: { | ||
duration: ms('1hour'), | ||
max: 300, | ||
}, | ||
|
||
errors: { | ||
}, | ||
} as const; | ||
|
||
export const paramDef = { | ||
type: 'object', | ||
properties: { | ||
}, | ||
required: [], | ||
} as const; | ||
|
||
@Injectable() | ||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export | ||
constructor( | ||
@Inject(DI.noteScheduleRepository) | ||
private noteScheduleRepository: NoteScheduleRepository, | ||
private userEntityService: UserEntityService, | ||
) { | ||
super(meta, paramDef, async (ps, me) => { | ||
const scheduleNotes = await this.noteScheduleRepository.findBy({ userId: me.id }); | ||
const user = await this.userEntityService.pack(me, me); | ||
scheduleNotes.forEach((item: any) => { | ||
item.note.user = user; | ||
item.note.createdAt = new Date(item.expiresAt); | ||
item.note.isSchedule = true; | ||
item.note.id = item.id; | ||
}); | ||
return scheduleNotes; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.