mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
using Govor.Core.Models.Users;
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
using Govor.API.Services.AdminsStuff.Interfaces;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Application.Interfaces;
|
||||
using Govor.Core.Models.Users;
|
||||
using Govor.Core.Repositories.Users;
|
||||
using Govor.Data.Repositories.Exceptions;
|
||||
|
||||
namespace Govor.Application.Interfaces.AdminsStuff;
|
||||
namespace Govor.Application.Infrastructure.AdminsStuff;
|
||||
|
||||
public class UsersService : IUsersAdministration
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Users;
|
||||
|
||||
namespace Govor.API.Services.Authentication.Interfaces;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Users;
|
||||
|
||||
namespace Govor.API.Services.Authentication.Interfaces;
|
||||
namespace Govor.Application.Interfaces.Authentication;
|
||||
|
||||
public interface IJwtService
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Users;
|
||||
|
||||
namespace Govor.Application.Interfaces.Friends;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Users;
|
||||
|
||||
namespace Govor.Application.Interfaces;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Govor.Application.Interfaces.Messages.Parameters;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Users;
|
||||
|
||||
namespace Govor.Application.Interfaces;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Messages;
|
||||
|
||||
namespace Govor.Application.Interfaces;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Users;
|
||||
|
||||
namespace Govor.API.Services.AdminsStuff.Interfaces;
|
||||
namespace Govor.Application.Interfaces;
|
||||
|
||||
public interface IUsersAdministration
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Messages;
|
||||
|
||||
namespace Govor.Application.Interfaces.Medias;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Govor.Application.Interfaces.Messages.Parameters;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Messages;
|
||||
|
||||
namespace Govor.Application.Interfaces.Messages;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Messages;
|
||||
|
||||
namespace Govor.Application.Interfaces.Messages.Parameters;
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Govor.API.Services.Authentication.Interfaces;
|
||||
using Govor.Application.Exceptions.AuthService;
|
||||
using Govor.Core.Infrastructure.Extensions;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Repositories.Users;
|
||||
using Govor.Application.Interfaces.Authentication;
|
||||
using Govor.Core.Infrastructure.Validators;
|
||||
using Govor.Core.Models.Users;
|
||||
using Govor.Core.Repositories.Admins;
|
||||
|
||||
namespace Govor.Application.Services.Authentication;
|
||||
|
||||
@@ -2,7 +2,8 @@ using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using Govor.API.Services.Authentication.Interfaces;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Application.Interfaces.Authentication;
|
||||
using Govor.Core.Models.Users;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Govor.Application.Exceptions.FriendsService;
|
||||
using Govor.Application.Interfaces.Friends;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Users;
|
||||
using Govor.Core.Repositories.Friendships;
|
||||
using Govor.Core.Repositories.Users;
|
||||
using Govor.Data.Repositories.Exceptions;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Govor.API.Services.Authentication.Interfaces;
|
||||
using Govor.Application.Exceptions.InvitesService;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Users;
|
||||
using Govor.Core.Repositories.Invaites;
|
||||
using Govor.Data.Repositories.Exceptions;
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@ using Govor.Application.Interfaces;
|
||||
using Govor.Application.Interfaces.Messages;
|
||||
using Govor.Application.Interfaces.Messages.Parameters;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Messages;
|
||||
using Govor.Core.Repositories.Groups;
|
||||
using Govor.Core.Repositories.Messages;
|
||||
using Govor.Core.Repositories.PrivateChats;
|
||||
using Govor.Core.Repositories.Users;
|
||||
using Govor.Data.Repositories.Exceptions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Govor.Application.Services.Messages;
|
||||
@@ -183,11 +185,14 @@ public class MessageCommandService : IMessageCommandService
|
||||
// return new DeleteMessageResult(false, new UnauthorizedAccessException("User is not authorized to delete this message."), null);
|
||||
// }
|
||||
// } else {
|
||||
_logger.LogWarning("User {DeleterId} attempted to delete message {MessageId} not sent by them (sender was {SenderId})", deleteParams.DeleterId, deleteParams.MessageId, message.SenderId);
|
||||
return new DeleteMessageResult(false, new UnauthorizedAccessException("User is not authorized to delete this message."), default);
|
||||
_logger.LogWarning(
|
||||
"User {DeleterId} attempted to delete message {MessageId} not sent by them (sender was {SenderId})",
|
||||
deleteParams.DeleterId, deleteParams.MessageId, message.SenderId);
|
||||
return new DeleteMessageResult(false,
|
||||
new UnauthorizedAccessException("User is not authorized to delete this message."), default);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
var originalMessageForNotification = new Message
|
||||
{
|
||||
Id = message.Id,
|
||||
@@ -195,12 +200,17 @@ public class MessageCommandService : IMessageCommandService
|
||||
RecipientId = message.RecipientId,
|
||||
RecipientType = message.RecipientType,
|
||||
};
|
||||
|
||||
|
||||
await _messagesRepository.RemoveAsync(deleteParams.MessageId);
|
||||
|
||||
_logger.LogInformation("Message {MessageId} deleted successfully by user {DeleterId}", deleteParams.MessageId, deleteParams.DeleterId);
|
||||
|
||||
_logger.LogInformation("Message {MessageId} deleted successfully by user {DeleterId}",
|
||||
deleteParams.MessageId, deleteParams.DeleterId);
|
||||
return new DeleteMessageResult(true, default, originalMessageForNotification);
|
||||
}
|
||||
catch (NotFoundByKeyException<Guid> ex)
|
||||
{
|
||||
return new DeleteMessageResult(false, new KeyNotFoundException("Message not found", ex), default);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error deleting message {MessageId} by user {DeleterId}", deleteParams.MessageId, deleteParams.DeleterId);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Govor.Application.Interfaces;
|
||||
using Govor.Core.Models;
|
||||
using Govor.Core.Models.Messages;
|
||||
using Govor.Core.Repositories.Groups;
|
||||
using Govor.Core.Repositories.Messages;
|
||||
using Govor.Data.Repositories.Exceptions;
|
||||
|
||||
Reference in New Issue
Block a user