forRoles IS NOT NULL, coalesce to empty=unrestricted

This commit is contained in:
наб 2025-07-22 00:26:05 +02:00
parent f3b5c3f447
commit b61c1d5b27
No known key found for this signature in database
GPG key ID: BCFD0B018D2658F1
9 changed files with 16 additions and 16 deletions

View file

@ -63,7 +63,7 @@ export class AnnouncementService {
}))
.andWhere(new Brackets(qb => {
qb.orWhere('announcement.forRoles && :roles', { roles: roles.map((r) => r.id) });
qb.orWhere('announcement.forRoles IS NULL');
qb.orWhere('announcement.forRoles = \'{}\'');
}))
.andWhere(`announcement.id NOT IN (${ readsQuery.getQuery() })`);

View file

@ -69,9 +69,9 @@ export class MiAnnouncement {
@Column('text', {
array: true,
default: null, nullable: true,
default: '{}', nullable: false,
})
public forRoles: MiRole['id'][] | null;
public forRoles: MiRole['id'][];
@Index()
@Column('boolean', {

View file

@ -59,7 +59,7 @@ export const paramDef = {
icon: { type: 'string', enum: ['info', 'warning', 'error', 'success'], default: 'info' },
display: { type: 'string', enum: ['normal', 'banner', 'dialog'], default: 'normal' },
forExistingUsers: { type: 'boolean', default: false },
forRoles: { type: 'array', nullable: true, default: null, items: { type: 'string', nullable: false, format: 'misskey:id' }, },
forRoles: { type: 'array', default: [], items: { type: 'string', nullable: false, format: 'misskey:id' }, },
silence: { type: 'boolean', default: false },
needConfirmationToRead: { type: 'boolean', default: false },
confetti: { type: 'boolean', default: false },

View file

@ -59,7 +59,7 @@ export const meta = {
},
forRoles: {
type: 'array',
optional: false, nullable: true,
optional: false, nullable: false,
items: {
type: 'string',
optional: false, nullable: false,

View file

@ -36,7 +36,7 @@ export const paramDef = {
icon: { type: 'string', enum: ['info', 'warning', 'error', 'success'] },
display: { type: 'string', enum: ['normal', 'banner', 'dialog'] },
forExistingUsers: { type: 'boolean' },
forRoles: { type: 'array', nullable: true, default: null, items: { type: 'string', nullable: false, format: 'misskey:id' }, },
forRoles: { type: 'array', default: [], items: { type: 'string', nullable: false, format: 'misskey:id' }, },
silence: { type: 'boolean' },
needConfirmationToRead: { type: 'boolean' },
confetti: { type: 'boolean' },

View file

@ -65,7 +65,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}))
.andWhere(new Brackets(qb => {
if (me) qb.orWhere('announcement.forRoles && :roles', { roles: roles.map((r) => r.id) });
qb.orWhere('announcement.forRoles IS NULL');
qb.orWhere('announcement.forRoles = \'{}\'');
}));
const announcements = await query.limit(ps.limit).getMany();