Skip to content

Commit

Permalink
fix(backend): 채널에서 노트 게시 예약을 사용하면 채널 타임라인이 아닌 일반 타임라인에 게시됨 (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
noridev committed Feb 1, 2025
1 parent 9bf4e7a commit e5bdb3f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_CHERRYPICK.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Misskey의 전체 변경 사항을 확인하려면, [CHANGELOG.md#2024xx](CHANGE
### Server
- Fix: 신고 즉시 해결 기능에서 발생할 수 있는 일부 문제 해결 ([misskey-dev/misskey#11032 (review)](https://github.com/misskey-dev/misskey/pull/11032#pullrequestreview-2425669540))
- forward가 `true`가 되면 `false`로 변경할 수 없음
- Fix: 채널에서 `노트 게시 예약`을 사용하면 채널 타임라인이 아닌 일반 타임라인에 게시됨 (kokonect-link/cherrypick#559)

---

Expand Down
15 changes: 13 additions & 2 deletions packages/backend/src/server/api/endpoints/notes/schedule/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
BlockingsRepository,
DriveFilesRepository,
ChannelsRepository,
NoteScheduleRepository,
NoteScheduleRepository, MiChannel,
} from '@/models/_.js';
import type { MiDriveFile } from '@/models/DriveFile.js';
import type { MiNote } from '@/models/Note.js';
Expand Down Expand Up @@ -148,6 +148,7 @@ export const paramDef = {
noExtractEmojis: { type: 'boolean', default: false },
replyId: { type: 'string', format: 'misskey:id', nullable: true },
renoteId: { type: 'string', format: 'misskey:id', nullable: true },
channelId: { type: 'string', format: 'misskey:id', nullable: true },

// anyOf内にバリデーションを書いても最初の一つしかチェックされない
// See https://github.com/misskey-dev/misskey/pull/10082
Expand Down Expand Up @@ -366,6 +367,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
}

let channel: MiChannel | null = null;
if (ps.channelId != null) {
channel = await this.channelsRepository.findOneBy({ id: ps.channelId, isArchived: false });

if (channel == null) {
throw new ApiError(meta.errors.noSuchChannel);
}
}

if (typeof ps.scheduleNote.scheduledAt === 'number') {
if (ps.scheduleNote.scheduledAt < Date.now()) {
throw new ApiError(meta.errors.cannotCreateAlreadyExpiredSchedule);
Expand All @@ -384,7 +394,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
}

const note:MiScheduleNoteType = {
const note: MiScheduleNoteType = {
createdAt: new Date(ps.scheduleNote.scheduledAt!).toISOString(),
files: files.map(f => f.id),
poll: ps.poll ? {
Expand All @@ -400,6 +410,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
reactionAcceptance: ps.reactionAcceptance,
visibility: ps.visibility,
visibleUsers,
channel: channel?.id,
apMentions: ps.noExtractMentions ? [] : undefined,
apHashtags: ps.noExtractHashtags ? [] : undefined,
apEmojis: ps.noExtractEmojis ? [] : undefined,
Expand Down
2 changes: 2 additions & 0 deletions packages/cherrypick-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25109,6 +25109,8 @@ export type operations = {
replyId?: string | null;
/** Format: misskey:id */
renoteId?: string | null;
/** Format: misskey:id */
channelId?: string | null;
text?: string | null;
fileIds?: string[];
mediaIds?: string[];
Expand Down

0 comments on commit e5bdb3f

Please sign in to comment.