Skip to content

Commit f914027

Browse files
UBERF-10672: Fix person duplicates (#9004)
1 parent 7f69a4c commit f914027

File tree

6 files changed

+233
-92
lines changed

6 files changed

+233
-92
lines changed

pods/server/src/rpc.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,21 @@ export function registerRPC (app: Express, sessions: SessionManager, ctx: Measur
344344
name: combineName(firstName, lastName),
345345
personUuid: uuid
346346
})
347+
const createUniquePersonTx = txFactory.createTxApplyIf(
348+
core.space.Workspace,
349+
socialId,
350+
[],
351+
[
352+
{
353+
_class: contact.class.Person,
354+
query: { personUuid: uuid }
355+
}
356+
],
357+
[createPersonTx],
358+
'createLocalPerson'
359+
)
347360

348-
await session.txRaw(ctx, createPersonTx)
361+
await session.txRaw(ctx, createUniquePersonTx)
349362
personRef = createPersonTx.objectId
350363
}
351364

services/mail/mail-common/src/__tests__/parseEmailHeader.test.ts

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ describe('parseEmailHeader', () => {
3636
expect(result).toEqual([
3737
{
3838
39-
firstName: 'test',
40-
lastName: 'example.com'
39+
firstName: 'test@example.com',
40+
lastName: ''
4141
}
4242
])
4343
})
@@ -47,8 +47,8 @@ describe('parseEmailHeader', () => {
4747
expect(result).toEqual([
4848
{
4949
50-
firstName: 'John',
51-
lastName: 'Doe'
50+
firstName: '<[email protected]>',
51+
lastName: 'John Doe'
5252
}
5353
])
5454
})
@@ -58,8 +58,8 @@ describe('parseEmailHeader', () => {
5858
expect(result).toEqual([
5959
{
6060
61-
firstName: 'John',
62-
lastName: 'Doe'
61+
firstName: '<[email protected]>',
62+
lastName: 'John Doe'
6363
}
6464
])
6565
})
@@ -69,8 +69,8 @@ describe('parseEmailHeader', () => {
6969
expect(result).toEqual([
7070
{
7171
72-
firstName: 'John',
73-
lastName: 'Doe Smith'
72+
firstName: '<[email protected]>',
73+
lastName: 'John Doe Smith'
7474
}
7575
])
7676
})
@@ -80,13 +80,13 @@ describe('parseEmailHeader', () => {
8080
expect(result).toEqual([
8181
{
8282
83-
firstName: 'test1',
84-
lastName: 'example.com'
83+
firstName: 'test1@example.com',
84+
lastName: ''
8585
},
8686
{
8787
88-
firstName: 'test2',
89-
lastName: 'example.com'
88+
firstName: 'test2@example.com',
89+
lastName: ''
9090
}
9191
])
9292
})
@@ -96,13 +96,13 @@ describe('parseEmailHeader', () => {
9696
expect(result).toEqual([
9797
{
9898
99-
firstName: 'John',
100-
lastName: 'example.com'
99+
firstName: '<[email protected]>',
100+
lastName: 'John'
101101
},
102102
{
103103
104-
firstName: 'Jane',
105-
lastName: 'Doe'
104+
firstName: '<[email protected]>',
105+
lastName: 'Jane Doe'
106106
}
107107
])
108108
})
@@ -112,13 +112,13 @@ describe('parseEmailHeader', () => {
112112
expect(result).toEqual([
113113
{
114114
115-
firstName: 'Doe,',
116-
lastName: 'John'
115+
firstName: '<[email protected]>',
116+
lastName: 'Doe, John'
117117
},
118118
{
119119
120-
firstName: 'Jane',
121-
lastName: 'Doe'
120+
firstName: '<[email protected]>',
121+
lastName: 'Jane Doe'
122122
}
123123
])
124124
})
@@ -128,13 +128,13 @@ describe('parseEmailHeader', () => {
128128
expect(result).toEqual([
129129
{
130130
131-
firstName: 'john',
132-
lastName: 'example.com'
131+
firstName: 'john@example.com',
132+
lastName: ''
133133
},
134134
{
135135
136-
firstName: 'Jane',
137-
lastName: 'Doe'
136+
firstName: '<[email protected]>',
137+
lastName: 'Jane Doe'
138138
}
139139
])
140140
})
@@ -144,13 +144,13 @@ describe('parseEmailHeader', () => {
144144
expect(result).toEqual([
145145
{
146146
147-
firstName: 'john',
148-
lastName: 'example.com'
147+
firstName: 'john@example.com',
148+
lastName: ''
149149
},
150150
{
151151
152-
firstName: 'jane',
153-
lastName: 'example.com'
152+
firstName: 'jane@example.com',
153+
lastName: ''
154154
}
155155
])
156156
})
@@ -160,13 +160,13 @@ describe('parseEmailHeader', () => {
160160
expect(result).toEqual([
161161
{
162162
163-
firstName: 'john',
164-
lastName: 'example.com'
163+
firstName: 'john@example.com',
164+
lastName: ''
165165
},
166166
{
167167
168-
firstName: 'Jane',
169-
lastName: 'Doe'
168+
firstName: '<[email protected]>',
169+
lastName: 'Jane Doe'
170170
}
171171
])
172172
})
@@ -176,13 +176,13 @@ describe('parseEmailHeader', () => {
176176
expect(result).toEqual([
177177
{
178178
179-
firstName: 'example',
180-
lastName: 'staff'
179+
firstName: '<example[email protected]>',
180+
lastName: 'example staff'
181181
},
182182
{
183183
184-
firstName: 'personnel',
185-
lastName: 'example.com'
184+
firstName: '<personnel@example.com>',
185+
lastName: 'personnel'
186186
}
187187
])
188188
})
@@ -192,13 +192,13 @@ describe('parseEmailHeader', () => {
192192
expect(result).toEqual([
193193
{
194194
195-
firstName: 'abc',
196-
lastName: 'test.com'
195+
firstName: 'abc@test.com',
196+
lastName: ''
197197
},
198198
{
199199
200-
firstName: '123',
201-
lastName: 'test.com'
200+
firstName: '123@test.com',
201+
lastName: ''
202202
}
203203
])
204204
})
@@ -208,13 +208,13 @@ describe('parseEmailHeader', () => {
208208
expect(result).toEqual([
209209
{
210210
211-
firstName: 'John',
212-
lastName: 'example.com'
211+
firstName: '<[email protected]>',
212+
lastName: 'John'
213213
},
214214
{
215215
216-
firstName: 'Jane',
217-
lastName: 'example.com'
216+
firstName: '<[email protected]>',
217+
lastName: 'Jane'
218218
}
219219
])
220220
})
@@ -224,13 +224,13 @@ describe('parseEmailHeader', () => {
224224
expect(result).toEqual([
225225
{
226226
227-
firstName: 'John',
228-
lastName: 'example.com'
227+
firstName: '<[email protected]>',
228+
lastName: 'John'
229229
},
230230
{
231231
232-
firstName: 'Jane',
233-
lastName: 'example.com'
232+
firstName: '<[email protected]>',
233+
lastName: 'Jane'
234234
}
235235
])
236236
})

services/mail/mail-common/src/__tests__/parseNameFromEmailHeader.test.ts

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
//
2+
// Copyright © 2025 Hardcore Engineering Inc.
3+
//
4+
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License. You may
6+
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
//
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
116
import { parseNameFromEmailHeader } from '../utils'
217
import { EmailContact } from '../types'
318

@@ -6,8 +21,8 @@ describe('parseNameFromEmailHeader', () => {
621
const input = '"John Doe" <[email protected]>'
722
const expected: EmailContact = {
823
9-
firstName: 'John',
10-
lastName: 'Doe'
24+
firstName: '<[email protected]>',
25+
lastName: 'John Doe'
1126
}
1227

1328
expect(parseNameFromEmailHeader(input)).toEqual(expected)
@@ -17,8 +32,8 @@ describe('parseNameFromEmailHeader', () => {
1732
const input = 'Jane Smith <[email protected]>'
1833
const expected: EmailContact = {
1934
20-
firstName: 'Jane',
21-
lastName: 'Smith'
35+
firstName: '<[email protected]>',
36+
lastName: 'Jane Smith'
2237
}
2338

2439
expect(parseNameFromEmailHeader(input)).toEqual(expected)
@@ -28,8 +43,8 @@ describe('parseNameFromEmailHeader', () => {
2843
const input = '[email protected]'
2944
const expected: EmailContact = {
3045
31-
firstName: 'no-reply',
32-
lastName: 'example.com'
46+
firstName: 'no-reply@example.com',
47+
lastName: ''
3348
}
3449

3550
expect(parseNameFromEmailHeader(input)).toEqual(expected)
@@ -39,8 +54,8 @@ describe('parseNameFromEmailHeader', () => {
3954
const input = '<[email protected]>'
4055
const expected: EmailContact = {
4156
42-
firstName: 'support',
43-
lastName: 'example.com'
57+
firstName: 'support@example.com',
58+
lastName: ''
4459
}
4560

4661
expect(parseNameFromEmailHeader(input)).toEqual(expected)
@@ -50,8 +65,8 @@ describe('parseNameFromEmailHeader', () => {
5065
const input = 'Maria Van Der Berg <[email protected]>'
5166
const expected: EmailContact = {
5267
53-
firstName: 'Maria',
54-
lastName: 'Van Der Berg'
68+
firstName: '<[email protected]>',
69+
lastName: 'Maria Van Der Berg'
5570
}
5671

5772
expect(parseNameFromEmailHeader(input)).toEqual(expected)
@@ -82,8 +97,8 @@ describe('parseNameFromEmailHeader', () => {
8297
const input = 'John Doe [email protected]'
8398
const expected: EmailContact = {
8499
email: 'John Doe [email protected]',
85-
firstName: 'John Doe john.doe',
86-
lastName: 'example.com'
100+
firstName: 'John Doe john.doe@example.com',
101+
lastName: ''
87102
}
88103

89104
expect(parseNameFromEmailHeader(input)).toEqual(expected)
@@ -93,8 +108,8 @@ describe('parseNameFromEmailHeader', () => {
93108
const input = 'Support <[email protected]>'
94109
const expected: EmailContact = {
95110
96-
firstName: 'Support',
97-
lastName: 'example.com'
111+
firstName: '<[email protected]>',
112+
lastName: 'Support'
98113
}
99114

100115
expect(parseNameFromEmailHeader(input)).toEqual(expected)
@@ -104,8 +119,8 @@ describe('parseNameFromEmailHeader', () => {
104119
const input = '"O\'Neill, James" <[email protected]>'
105120
const expected: EmailContact = {
106121
107-
firstName: "O'Neill,",
108-
lastName: 'James'
122+
firstName: '<[email protected]>',
123+
lastName: "O'Neill, James"
109124
}
110125

111126
expect(parseNameFromEmailHeader(input)).toEqual(expected)

0 commit comments

Comments
 (0)