mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
firebase sdk update + sql options
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Security;
|
||||
using Govor.Core.Infrastructure.Extensions;
|
||||
using Govor.Core.Models.Users;
|
||||
using Govor.Core.Repositories.PushTokens;
|
||||
@@ -62,10 +63,13 @@ public class PushTokenRepository : IPushTokenRepository
|
||||
throw new ArgumentException("Platform cannot be empty", nameof(platform));
|
||||
|
||||
var existing = await _context.UserPushTokens
|
||||
.FirstOrDefaultAsync(t => t.UserSessionId == sessionId);
|
||||
|
||||
.FirstOrDefaultAsync(t => t.UserSessionId == sessionId && t.Platform == platform);
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
if(existing.UserId != userId)
|
||||
throw new SecurityException("Token already belongs to another user");
|
||||
|
||||
// Updates
|
||||
existing.UserId = userId;
|
||||
existing.UserSessionId = sessionId;
|
||||
@@ -113,7 +117,12 @@ public class PushTokenRepository : IPushTokenRepository
|
||||
|
||||
if (toRemove.Any())
|
||||
{
|
||||
_context.UserPushTokens.RemoveRange(toRemove);
|
||||
foreach (var token in toRemove)
|
||||
{
|
||||
token.IsActive = false;
|
||||
_context.UserPushTokens.Update(token);
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,6 @@ public class UserSessionsRepository : IUserSessionsRepository
|
||||
.SetProperty(a => a.UserId, userSession.UserId)
|
||||
.SetProperty(u => u.RefreshTokenHash, userSession.RefreshTokenHash)
|
||||
.SetProperty(u => u.DeviceInfo, userSession.DeviceInfo)
|
||||
.SetProperty(u => u.CreatedAt, userSession.CreatedAt)
|
||||
.SetProperty(u => u.ExpiresAt, userSession.ExpiresAt)
|
||||
.SetProperty(u => u.IsRevoked, userSession.IsRevoked)
|
||||
);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class UsersRepository : IUsersRepository
|
||||
!_context.Friendships.Any(f =>
|
||||
((f.RequesterId == currentUserId && f.AddresseeId == u.Id) ||
|
||||
(f.RequesterId == u.Id && f.AddresseeId == currentUserId)) && f.Status != FriendshipStatus.Rejected))
|
||||
.Take(10)
|
||||
.Take(7)
|
||||
.OrderBy(u => u.Username)
|
||||
.ToListOrThrowIfEmpty(new NotFoundByKeyException<(string, Guid)>((query, currentUserId), $"Users with given query for user {currentUserId} not found"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user