Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions services/apps/data_sink_worker/src/service/member.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ export default class MemberService extends LoggerBase {
}
}

const isBotMember = this.botDetectionService.isFlaggedAsBot(
attributes as Record<string, unknown>,
)

const emailIdentities = data.identities.filter(
(i) => i.type === MemberIdentityType.EMAIL && i.verified,
)
Expand All @@ -514,6 +518,7 @@ export default class MemberService extends LoggerBase {
orgPromiseCache,
effectiveMemberId,
activityTimestamp,
isBotMember,
),
this.log,
'memberService -> create -> assignOrganizationByEmailDomain',
Expand Down Expand Up @@ -693,7 +698,11 @@ export default class MemberService extends LoggerBase {
}
}

if (this.botDetectionService.isFlaggedAsBot(toUpdate.attributes)) {
const isBotMember = this.botDetectionService.isFlaggedAsBot(
original.attributes as Record<string, unknown>,
)

if (isBotMember) {
this.log.debug({ memberId: id }, 'Skipping organization creation for bot member')
return effectiveMemberId !== id ? effectiveMemberId : undefined
}
Expand Down Expand Up @@ -752,6 +761,7 @@ export default class MemberService extends LoggerBase {
orgPromiseCache,
effectiveMemberId,
activityTimestamp,
isBotMember,
),
this.log,
'memberService -> update -> assignOrganizationByEmailDomain',
Expand Down Expand Up @@ -807,6 +817,7 @@ export default class MemberService extends LoggerBase {
orgPromiseCache?: Map<string, Promise<string | undefined>>,
memberId?: string,
activityTimestamp?: string,
isBotMember = false,
): Promise<IOrganizationIdSource[]> {
const orgService = new OrganizationService(this.store, this.log)
const organizations: IOrganizationIdSource[] = []
Expand Down Expand Up @@ -866,7 +877,8 @@ export default class MemberService extends LoggerBase {
id: orgId,
source: orgSource,
})
if (memberId && activityTimestamp) {

if (memberId && activityTimestamp && !isBotMember) {
await this.bufferMemberOrganizationActivityDates(memberId, orgId, activityTimestamp)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ export async function fetchMembersForLFIDEnrichment(db: DbStore, limit: number,
(mi.type = 'email' and mi.verified)
)
AND members."deletedAt" IS NULL
AND coalesce((members.attributes -> 'isBot' ->> 'default')::boolean, false) = false
AND coalesce((members.attributes -> 'isOrganization' ->> 'default')::boolean, false) = false
${idFilter}
GROUP BY members.id
ORDER BY members.id desc
Expand Down
Loading