summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/chat/messages
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-06-28 20:21:21 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2025-06-28 20:21:21 +0900
commitb8e8f3ad25fafbe0567e710eddfcced04deb03ad (patch)
tree4847b140ad2a7b5c5c86e5cda61af2ff7e444853 /packages/backend/src/server/api/endpoints/chat/messages
parentenhance(frontend): improve MkTl rendering (diff)
downloadmisskey-b8e8f3ad25fafbe0567e710eddfcced04deb03ad.tar.gz
misskey-b8e8f3ad25fafbe0567e710eddfcced04deb03ad.tar.bz2
misskey-b8e8f3ad25fafbe0567e710eddfcced04deb03ad.zip
enhance: ページネーション(一覧表示)の基準日時を指定できるように sinceId/untilIdが指定可能なエンドポイントにおいて、sinceDate/untilDateも指定可能に
Diffstat (limited to 'packages/backend/src/server/api/endpoints/chat/messages')
-rw-r--r--packages/backend/src/server/api/endpoints/chat/messages/room-timeline.ts9
-rw-r--r--packages/backend/src/server/api/endpoints/chat/messages/user-timeline.ts9
2 files changed, 16 insertions, 2 deletions
diff --git a/packages/backend/src/server/api/endpoints/chat/messages/room-timeline.ts b/packages/backend/src/server/api/endpoints/chat/messages/room-timeline.ts
index c0e344b889..dd598b5628 100644
--- a/packages/backend/src/server/api/endpoints/chat/messages/room-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/chat/messages/room-timeline.ts
@@ -9,6 +9,7 @@ import { DI } from '@/di-symbols.js';
import { ChatService } from '@/core/ChatService.js';
import { ChatEntityService } from '@/core/entities/ChatEntityService.js';
import { ApiError } from '@/server/api/error.js';
+import { IdService } from '@/core/IdService.js';
export const meta = {
tags: ['chat'],
@@ -42,6 +43,8 @@ export const paramDef = {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
sinceId: { type: 'string', format: 'misskey:id' },
untilId: { type: 'string', format: 'misskey:id' },
+ sinceDate: { type: 'integer' },
+ untilDate: { type: 'integer' },
roomId: { type: 'string', format: 'misskey:id' },
},
required: ['roomId'],
@@ -52,8 +55,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
constructor(
private chatEntityService: ChatEntityService,
private chatService: ChatService,
+ private idService: IdService,
) {
super(meta, paramDef, async (ps, me) => {
+ const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null);
+ const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.gen(ps.sinceDate!) : null);
+
await this.chatService.checkChatAvailability(me.id, 'read');
const room = await this.chatService.findRoomById(ps.roomId);
@@ -65,7 +72,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.noSuchRoom);
}
- const messages = await this.chatService.roomTimeline(room.id, ps.limit, ps.sinceId, ps.untilId);
+ const messages = await this.chatService.roomTimeline(room.id, ps.limit, sinceId, untilId);
this.chatService.readRoomChatMessage(me.id, room.id);
diff --git a/packages/backend/src/server/api/endpoints/chat/messages/user-timeline.ts b/packages/backend/src/server/api/endpoints/chat/messages/user-timeline.ts
index a057e2e088..52a13b2178 100644
--- a/packages/backend/src/server/api/endpoints/chat/messages/user-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/chat/messages/user-timeline.ts
@@ -10,6 +10,7 @@ import { GetterService } from '@/server/api/GetterService.js';
import { ChatService } from '@/core/ChatService.js';
import { ChatEntityService } from '@/core/entities/ChatEntityService.js';
import { ApiError } from '@/server/api/error.js';
+import { IdService } from '@/core/IdService.js';
export const meta = {
tags: ['chat'],
@@ -43,6 +44,8 @@ export const paramDef = {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
sinceId: { type: 'string', format: 'misskey:id' },
untilId: { type: 'string', format: 'misskey:id' },
+ sinceDate: { type: 'integer' },
+ untilDate: { type: 'integer' },
userId: { type: 'string', format: 'misskey:id' },
},
required: ['userId'],
@@ -54,8 +57,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private chatEntityService: ChatEntityService,
private chatService: ChatService,
private getterService: GetterService,
+ private idService: IdService,
) {
super(meta, paramDef, async (ps, me) => {
+ const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null);
+ const sinceId = ps.sinceId ?? (ps.sinceDate ? this.idService.gen(ps.sinceDate!) : null);
+
await this.chatService.checkChatAvailability(me.id, 'read');
const other = await this.getterService.getUser(ps.userId).catch(err => {
@@ -63,7 +70,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw err;
});
- const messages = await this.chatService.userTimeline(me.id, other.id, ps.limit, ps.sinceId, ps.untilId);
+ const messages = await this.chatService.userTimeline(me.id, other.id, ps.limit, sinceId, untilId);
this.chatService.readUserChatMessage(me.id, other.id);