forked from gongxuegit/tiku-backend.net
feat: establish dotnet engineering foundation
This commit is contained in:
@@ -1263,7 +1263,7 @@ public sealed class TenantAdminDirectService(TikuDbContext dbContext) : ITenantA
|
||||
GrantedBy = actor.UserId,
|
||||
GrantedAt = command.GrantedAt ?? DateTimeOffset.UtcNow
|
||||
};
|
||||
grant.LegacyId = Normalize(command.LegacyId) ?? grant.LegacyId ?? $"badge:{command.BadgeId}:user:{command.UserId}";
|
||||
grant.LegacyId = Normalize(command.LegacyId) ?? grant.LegacyId;
|
||||
grant.Note = Normalize(command.Note) ?? grant.Note;
|
||||
grant.GrantedBy ??= actor.UserId;
|
||||
grant.GrantedAt ??= command.GrantedAt ?? DateTimeOffset.UtcNow;
|
||||
@@ -1272,19 +1272,20 @@ public sealed class TenantAdminDirectService(TikuDbContext dbContext) : ITenantA
|
||||
dbContext.UserBadges.Add(grant);
|
||||
}
|
||||
|
||||
var dedupeKey = $"badge:{grant.Id:N}";
|
||||
var notification = await dbContext.UserNotifications.FirstOrDefaultAsync(
|
||||
item =>
|
||||
item.TenantId == actor.TenantId &&
|
||||
item.UserId == command.UserId &&
|
||||
item.NotificationType == "badge_granted" &&
|
||||
item.DedupeKey == grant.LegacyId,
|
||||
item.DedupeKey == dedupeKey,
|
||||
cancellationToken);
|
||||
notification ??= new UserNotification
|
||||
{
|
||||
TenantId = actor.TenantId,
|
||||
UserId = command.UserId,
|
||||
NotificationType = "badge_granted",
|
||||
DedupeKey = grant.LegacyId,
|
||||
DedupeKey = dedupeKey,
|
||||
CreatedBy = actor.UserId
|
||||
};
|
||||
notification.Severity = NotificationSeverity.Success;
|
||||
|
||||
Reference in New Issue
Block a user