Skip to content

Commit 573c097

Browse files
authored
Fix adding user properties to UserInfo context (#243)
* Fix updating the user preferences * Fix adding user properties to UserInfo context * Fix adding user properties to UserInfo context * Make the dictionaries merge code more imperative
1 parent fe94068 commit 573c097

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

backend/src/Notifo.Domain/Integrations/IntegrationExtensions.cs

+19-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,31 @@
66
// ==========================================================================
77

88
using Notifo.Domain.Users;
9+
using Notifo.Infrastructure.Collections;
10+
using System.Collections.Generic;
911

1012
namespace Notifo.Domain.Integrations;
1113

1214
public static class IntegrationExtensions
1315
{
1416
public static UserInfo ToContext(this User user)
1517
{
16-
return new UserInfo { Id = user.Id, EmailAddress = user.EmailAddress, PhoneNumber = user.PhoneNumber, Properties = user.SystemProperties };
18+
var properties = new Dictionary<string, string>(user.Properties);
19+
20+
if (user.SystemProperties != null)
21+
{
22+
foreach (var (key, value) in user.SystemProperties)
23+
{
24+
properties[key] = value;
25+
}
26+
}
27+
28+
return new UserInfo
29+
{
30+
Id = user.Id,
31+
EmailAddress = user.EmailAddress,
32+
PhoneNumber = user.PhoneNumber,
33+
Properties = properties.ToReadonlyDictionary()
34+
};
1735
}
1836
}

0 commit comments

Comments
 (0)