feat: add taggedOrgs feature
This commit is contained in:
@@ -4,6 +4,7 @@ import { orgModel } from "../organization/organization.schema";
|
||||
import {
|
||||
getFilterObject,
|
||||
getSortObject,
|
||||
getTaggedOrgsFilter,
|
||||
getTaggedUsersFilter,
|
||||
PageQueryParams,
|
||||
} from "../pagination";
|
||||
@@ -56,11 +57,7 @@ export async function updateNotification(
|
||||
user: AuthenticatedUser,
|
||||
) {
|
||||
if (input.assignedToOrg && input.assignedTo) {
|
||||
input.assignedTo = [];
|
||||
} else if (input.assignedToOrg) {
|
||||
input.assignedTo = [];
|
||||
} else if (input.assignedTo) {
|
||||
input.assignedToOrg = null;
|
||||
delete input.assignedTo;
|
||||
}
|
||||
|
||||
const oldNotification = await notificationModel.findOne(
|
||||
@@ -208,12 +205,18 @@ export async function listNotifications(
|
||||
});
|
||||
}
|
||||
|
||||
let { taggedFilter, taggedUserFilterIndex } = getTaggedUsersFilter(
|
||||
let { taggedUsersFilter, taggedUserFilterIndex } = getTaggedUsersFilter(
|
||||
filterObj,
|
||||
sortObj,
|
||||
);
|
||||
|
||||
let { taggedOrgsFilter, taggedOrgsFilterIndex } = getTaggedOrgsFilter(
|
||||
filterObj,
|
||||
sortObj,
|
||||
);
|
||||
|
||||
if (taggedUserFilterIndex != -1) filterObj.splice(taggedUserFilterIndex, 1);
|
||||
if (taggedOrgsFilterIndex != -1) filterObj.splice(taggedOrgsFilterIndex, 1);
|
||||
|
||||
const pipeline: any = [
|
||||
{
|
||||
@@ -232,7 +235,8 @@ export async function listNotifications(
|
||||
|
||||
pipeline.push(
|
||||
...[
|
||||
...taggedFilter,
|
||||
...taggedUsersFilter,
|
||||
...taggedOrgsFilter,
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
@@ -259,6 +263,7 @@ export async function listNotifications(
|
||||
createdAt: 1,
|
||||
updatedAt: 1,
|
||||
taggedUsers: 1,
|
||||
taggedOrgs: 1,
|
||||
assignedToOrg: 1,
|
||||
assignedTo: {
|
||||
$map: {
|
||||
|
||||
Reference in New Issue
Block a user