Revert "feat: お知らせの優先順位機能 (#118)"

This reverts commit fe0f7a91a3.
This commit is contained in:
まっちゃとーにゅ
2023-08-15 16:44:54 +09:00
parent eeef3965b7
commit 04fefb2056
12 changed files with 69 additions and 131 deletions

View File

@@ -47,10 +47,6 @@ export const meta = {
type: 'string',
optional: false, nullable: true,
},
displayOrder: {
type: 'number',
optional: false, nullable: false,
},
userId: {
type: 'string',
optional: false, nullable: true,
@@ -69,7 +65,6 @@ export const paramDef = {
title: { type: 'string', minLength: 1 },
text: { type: 'string', minLength: 1 },
imageUrl: { type: 'string', nullable: true, minLength: 1 },
displayOrder: { type: 'number' },
userId: { type: 'string', nullable: true, format: 'misskey:id' },
closeDuration: { type: 'number', nullable: false },
},
@@ -93,7 +88,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
title: ps.title,
text: ps.text,
imageUrl: ps.imageUrl,
displayOrder: ps.displayOrder,
userId: ps.userId ?? null,
closeDuration: ps.closeDuration,
}).then(x => this.announcementsRepository.findOneByOrFail(x.identifiers[0]));

View File

@@ -53,10 +53,6 @@ export const meta = {
type: 'string',
optional: false, nullable: true,
},
displayOrder: {
type: 'number',
optional: false, nullable: false,
},
userId: {
type: 'string',
optional: false, nullable: true,
@@ -83,7 +79,8 @@ export const paramDef = {
type: 'object',
properties: {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
offset: { type: 'integer', default: 0 },
sinceId: { type: 'string', format: 'misskey:id' },
untilId: { type: 'string', format: 'misskey:id' },
userId: { type: 'string', format: 'misskey:id' },
},
required: [],
@@ -102,25 +99,20 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,
private queryService: QueryService,
private userEntityService: UserEntityService,
) {
super(meta, paramDef, async (ps, me) => {
const query = this.announcementsRepository.createQueryBuilder('announcement');
const builder = this.announcementsRepository.createQueryBuilder('announcement');
if (ps.userId) {
query.where('"userId" = :userId', { userId: ps.userId });
builder.where('"userId" = :userId', { userId: ps.userId });
} else {
query.where('"userId" IS NULL');
builder.where('"userId" IS NULL');
}
query.orderBy({
'announcement."displayOrder"': 'DESC',
'announcement."createdAt"': 'DESC',
});
const query = this.queryService.makePaginationQuery(builder, ps.sinceId, ps.untilId);
const announcements = await query
.offset(ps.offset)
.limit(ps.limit)
.getMany();
const announcements = await query.limit(ps.limit).getMany();
const reads = new Map<Announcement, number>();
@@ -144,7 +136,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
title: announcement.title,
text: announcement.text,
imageUrl: announcement.imageUrl,
displayOrder: announcement.displayOrder,
userId: announcement.userId,
user: packedUsers.find(user => user.id === announcement.userId),
reads: reads.get(announcement)!,

View File

@@ -31,7 +31,6 @@ export const paramDef = {
title: { type: 'string', minLength: 1 },
text: { type: 'string', minLength: 1 },
imageUrl: { type: 'string', nullable: true, minLength: 0 },
displayOrder: { type: 'number' },
userId: { type: 'string', nullable: true, format: 'misskey:id' },
closeDuration: { type: 'number', nullable: false },
},
@@ -63,7 +62,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
text: ps.text,
/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- 空の文字列の場合、nullを渡すようにするため */
imageUrl: ps.imageUrl || null,
displayOrder: ps.displayOrder,
userId: ps.userId ?? null,
closeDuration: ps.closeDuration,
});