Skip to content

Commit

Permalink
Merge branch 'main' into oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
skwowet authored Jul 10, 2023
2 parents 4ad459b + e4d3bfd commit 85dbc7e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
21 changes: 21 additions & 0 deletions backend/src/services/memberService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,27 @@ export default class MemberService extends LoggerBase {
organizationsIds.push(organizationRecord.id)
}
}

// Auto assign member to organization if email domain matches
if (data.emails) {
const emailDomains = new Set()

// Collect unique domains
for (const email of data.emails) {
const domain = email.split('@')[1]
emailDomains.add(domain)
}

// Fetch organization ids for these domains
const organizationService = new OrganizationService(this.options)
for (const domain of emailDomains) {
const organizationRecord = await organizationService.findByUrl(domain)
if (organizationRecord) {
organizationsIds.push(organizationRecord.id)
}
}
}

// Remove dups
data.organizations = [...new Set(organizationsIds)]
}
Expand Down
4 changes: 4 additions & 0 deletions backend/src/services/organizationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ export default class OrganizationService extends LoggerBase {
return OrganizationRepository.findAndCountAll(args, this.options)
}

async findByUrl(url) {
return OrganizationRepository.findByUrl(url, this.options)
}

async query(data) {
const advancedFilter = data.filter
const orderBy = data.orderBy
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/layout/components/layout.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<el-container>
<app-menu />
<el-container :style="elMainStyle">
<el-container v-if="currentTenant" :style="elMainStyle">
<el-main id="main-page-wrapper" class="relative">
<div
:class="{
Expand Down
18 changes: 4 additions & 14 deletions services/apps/data_sink_worker/src/repo/dataSink.repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,10 @@ export default class DataSinkRepository extends RepositoryBase<DataSinkRepositor
this.checkUpdateRowCount(result.rowCount, 1)
}

public async markResultProcessed(resultId: string): Promise<void> {
const result = await this.db().result(
`update integration.results
set state = $(state),
"processedAt" = now(),
"updatedAt" = now()
where id = $(resultId)`,
{
resultId,
state: IntegrationResultState.PROCESSED,
},
)

this.checkUpdateRowCount(result.rowCount, 1)
public async deleteResult(resultId: string): Promise<void> {
await this.db().none(`delete from integration.results where id = $(resultId)`, {
resultId,
})
}

public async touchRun(runId: string): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default class DataSinkService extends LoggerBase {
throw new Error(`Unknown result type: ${data.type}`)
}
}
await this.repo.markResultProcessed(resultId)
await this.repo.deleteResult(resultId)
} catch (err) {
this.log.error(err, 'Error processing result.')
await this.triggerResultError(
Expand Down

0 comments on commit 85dbc7e

Please sign in to comment.