Skip to content

Commit 9553e2c

Browse files
committed
refactor: streamline email domain extraction logic in ActivityService
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent 68a79fc commit 9553e2c

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

services/apps/data_sink_worker/src/service/activity.service.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
distinctBy,
1010
escapeNullByte,
1111
generateUUIDv1,
12+
isDomainExcluded,
1213
isValidEmail,
1314
parseGitHubNoreplyEmail,
1415
single,
@@ -1450,12 +1451,10 @@ export default class ActivityService extends LoggerBase {
14501451
) as boolean
14511452

14521453
if (!isBot) {
1453-
const verifiedEmailIdentity = payload.activity.member.identities?.find(
1454-
(i) => i.type === MemberIdentityType.EMAIL && i.verified,
1455-
)
1456-
const emailDomain = verifiedEmailIdentity
1457-
? verifiedEmailIdentity.value.split('@')[1]
1458-
: undefined
1454+
const emailDomain = payload.activity.member.identities
1455+
?.filter((i) => i.type === MemberIdentityType.EMAIL && i.verified)
1456+
.map((i) => i.value.split('@')[1]?.toLowerCase())
1457+
.find((domain) => domain && !isDomainExcluded(domain))
14591458

14601459
// associate activity with organization
14611460
payload.organizationId = await this.commonMemberService.findAffiliation(

0 commit comments

Comments
 (0)