Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
  • Loading branch information
haiodo committed Aug 16, 2024
1 parent 5d5fbd9 commit 0b3d72d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
3 changes: 2 additions & 1 deletion plugins/contact-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ async function kickEmployee (doc: Person): Promise<void> {
(res?: boolean) => {
if (res === true) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
const p = getResource(login.function.LeaveWorkspace)
for (const i of accounts) {
void getResource(login.function.LeaveWorkspace).then(async (f) => {
void p.then(async (f) => {
await f(i.email)
})
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/contact-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ function fillStores (): void {
const accountPersonQuery = createQuery(true)

const query = createQuery(true)
query.query(contact.mixin.Employee, { [contact.mixin.Employee + '.active']: { $in: [true, false] } }, (res) => {
query.query(contact.mixin.Employee, { active: { $in: [true, false] } }, (res) => {
employeesStore.set(res)
employeeByIdStore.set(toIdMap(res))
})
Expand Down
5 changes: 4 additions & 1 deletion server-plugins/chunter-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@ export async function ChunterTrigger (tx: TxCUD<Doc>, control: TriggerControl):
))
)
}
if (control.hierarchy.isDerived(actualTx.objectClass, chunter.class.ThreadMessage)) {
if (
actualTx._class === core.class.TxRemoveDoc &&
control.hierarchy.isDerived(actualTx.objectClass, chunter.class.ThreadMessage)
) {
res.push(
...(await control.ctx.with(
'OnThreadMessageDeleted',
Expand Down
3 changes: 3 additions & 0 deletions server-plugins/notification-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,9 @@ async function removeContexts (
const res: Tx[] = []

for (const context of contexts) {
if (!unsubscribe.includes(context.user as Ref<PersonAccount>)) {
continue
}
const account = control.modelDb.getObject(context.user)
if (account === undefined) continue

Expand Down
23 changes: 20 additions & 3 deletions server-plugins/notification-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,16 +487,33 @@ export async function getUsersInfo (
await control.queryFind(
ctx,
contact.mixin.Employee,
{ [contact.mixin.Employee + '.active']: { $in: [true, false] } },
{ ctx }
{ active: { $in: [true, false] } },
{}
)
).filter((it) => personIdsMap.has(it._id))
)
for (const pp of p) {
persons.set(pp._id, pp)
}

const nonEmployee = personIds.filter(it => !persons.has(it))

const p2 = await ctx.with('find-persons', {}, async (ctx) =>
(
await control.queryFind(
ctx,
contact.class.Person,
{ _id: { $in: Array.from(nonEmployee) } },
{ }
)
).filter((it) => personIdsMap.has(it._id))
)
for (const pp of p2) {
persons.set(pp._id, pp)
}

const res = await ctx.with('find-person-spaces', {}, async (ctx) =>
(await control.queryFind(ctx, contact.class.PersonSpace, {}, { ctx })).filter((it) => personIdsMap.has(it.person))
(await control.queryFind(ctx, contact.class.PersonSpace, {}, { })).filter((it) => personIdsMap.has(it.person))
)
for (const r of res) {
spaces.set(r.person, r)
Expand Down
6 changes: 2 additions & 4 deletions server/mongo/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,7 @@ class MongoAdapter extends MongoAdapterBase {
{ domain },
() =>
coll.bulkWrite(ops, {
ordered: false,
writeConcern: { w: 0 }
ordered: false
}),
{
domain,
Expand Down Expand Up @@ -1541,8 +1540,7 @@ class MongoTxAdapter extends MongoAdapterBase implements TxAdapter {
this.txCollection().insertMany(
txes.map((it) => translateDoc(it)),
{
ordered: false,
writeConcern: { w: 0 }
ordered: false
}
),
{
Expand Down

0 comments on commit 0b3d72d

Please sign in to comment.