Skip to content

Commit

Permalink
VM-1483: short message model and forbid
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-buravlev committed Oct 24, 2024
1 parent b9f38f5 commit 92b4f8c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ public class MessageShort
{
public string SenderId { get; set; }
public string RecipientId { get; set; }
public string ProductId { get; set; }
public string EntityId { get; set; }
public string EntityType { get; set; }
public string Content { get; set; }
public string ReplyTo { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public virtual async Task<Unit> Handle(SendMessageCommand request, CancellationT
var message = AbstractTypeFactory<Message>.TryCreateInstance();
message.SenderId = request.Message.SenderId ?? (await GetOrCreateCommunicationUserForSeller(request.SellerId)).Id;
message.Content = request.Message.Content;
message.EntityId = request.Message.ProductId;
message.EntityId = request.Message.EntityId;
message.EntityId = request.Message.EntityType;
message.ThreadId = request.Message.ReplyTo;
message.EntityType = CoreModuleConstants.EntityType.Product;

var messageRecipient = AbstractTypeFactory<MessageRecipient>.TryCreateInstance();
messageRecipient.RecipientId = request.Message.RecipientId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task<ActionResult<SearchMessageResult>> Search([FromBody] SearchMes
var authorizationResult = await _authorizationService.AuthorizeAsync(User, query, new SellerAuthorizationRequirement(Core.ModuleConstants.Security.Permissions.Read));
if (!authorizationResult.Succeeded)
{
return Unauthorized();
return Forbid();
}
var result = await _mediator.Send(query);

Expand All @@ -46,7 +46,7 @@ public async Task<ActionResult> SendMessage([FromBody] SendMessageCommand comman
var authorizationResult = await _authorizationService.AuthorizeAsync(User, command, new SellerAuthorizationRequirement(Core.ModuleConstants.Security.Permissions.Send));
if (!authorizationResult.Succeeded)
{
return Unauthorized();
return Forbid();
}
var result = await _mediator.Send(command);

Expand All @@ -60,7 +60,7 @@ public async Task<ActionResult> UpdateMessage([FromBody] UpdateMessageCommand co
var authorizationResult = await _authorizationService.AuthorizeAsync(User, command, new SellerAuthorizationRequirement(Core.ModuleConstants.Security.Permissions.Edit));
if (!authorizationResult.Succeeded)
{
return Unauthorized();
return Forbid();
}
var result = await _mediator.Send(command);

Expand All @@ -74,7 +74,7 @@ public async Task<ActionResult> DeleteMessage([FromBody] DeleteMessageCommand co
var authorizationResult = await _authorizationService.AuthorizeAsync(User, command, new SellerAuthorizationRequirement(Core.ModuleConstants.Security.Permissions.Delete));
if (!authorizationResult.Succeeded)
{
return Unauthorized();
return Forbid();
}
var result = await _mediator.Send(command);

Expand All @@ -88,7 +88,7 @@ public async Task<ActionResult> MarkMessageAsRead([FromBody] MarkMessageAsReadCo
var authorizationResult = await _authorizationService.AuthorizeAsync(User, command, new SellerAuthorizationRequirement(Core.ModuleConstants.Security.Permissions.Read));
if (!authorizationResult.Succeeded)
{
return Unauthorized();
return Forbid();
}
var result = await _mediator.Send(command);

Expand All @@ -102,7 +102,7 @@ public async Task<ActionResult> SendReaction([FromBody] SendReactionCommand comm
var authorizationResult = await _authorizationService.AuthorizeAsync(User, command, new SellerAuthorizationRequirement(Core.ModuleConstants.Security.Permissions.Read));
if (!authorizationResult.Succeeded)
{
return Unauthorized();
return Forbid();
}
var result = await _mediator.Send(command);

Expand Down

0 comments on commit 92b4f8c

Please sign in to comment.