This commit is contained in:
naskya 2023-07-13 16:10:13 +00:00
parent 8ad603cba8
commit 22102d6c38
No known key found for this signature in database
GPG Key ID: 164DFF24E2D40139
2 changed files with 20 additions and 14 deletions

View File

@ -30,7 +30,7 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, user) => {
// Check if announcement exists
const exist = await Announcements.findOneBy({
const exist = await Announcements.exist({
where: { id: ps.announcementId },
});
@ -39,12 +39,14 @@ export default define(meta, paramDef, async (ps, user) => {
}
// Check if already read
const read = await AnnouncementReads.findOneBy({
const read = await AnnouncementReads.exist({
where: {
announcementId: ps.announcementId,
userId: user.id,
},
});
if (read != null) {
if (read) {
return;
}

View File

@ -52,14 +52,14 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => {
// Fetch the list
const userList = await UserLists.exist({
const listExists = await UserLists.exist({
where: {
id: ps.listId,
userId: me.id,
},
});
if (!exist) {
if (!listExists) {
throw new ApiError(meta.errors.noSuchList);
}
@ -72,18 +72,22 @@ export default define(meta, paramDef, async (ps, me) => {
// Check blocking
if (user.id !== me.id) {
const block = await Blockings.findOneBy({
const isBlocked = await Blockings.exist({
where: {
blockerId: user.id,
blockeeId: me.id,
},
});
if (block) {
if (isBlocked) {
throw new ApiError(meta.errors.youHaveBeenBlocked);
}
}
const exist = await UserListJoinings.findOneBy({
const exist = await UserListJoinings.exist({
where: {
userListId: userList.id,
userId: user.id,
},
});
if (exist) {