fix: align backend APIs and upload flow
This commit is contained in:
@@ -52,13 +52,16 @@ namespace MessageService.WebApi.Application.Message
|
||||
{
|
||||
MessageType.Text => Domain.Entities.Message.BuildTxt(ctx, command.Text!, sequenceId),
|
||||
|
||||
MessageType.Image => Domain.Entities.Message.BuildImg(ctx, command.Url!,
|
||||
command.Width ?? 0, command.Height ?? 0, command.Thumb!, sequenceId),
|
||||
MessageType.Image => Domain.Entities.Message.BuildImg(ctx, command.Url,
|
||||
command.Width ?? 0, command.Height ?? 0, command.Thumb!, sequenceId, command.FileId),
|
||||
|
||||
MessageType.Video => Domain.Entities.Message.BuildVideo(ctx, command.Url!,
|
||||
command.Width ?? 0, command.Height ?? 0, command.Thumb!, sequenceId),
|
||||
MessageType.Video => Domain.Entities.Message.BuildVideo(ctx, command.Url,
|
||||
command.Width ?? 0, command.Height ?? 0, command.Thumb!, sequenceId, command.FileId),
|
||||
|
||||
MessageType.Voice => Domain.Entities.Message.BuildVoice(ctx, command.Url!, command.Duration ?? 0, sequenceId),
|
||||
MessageType.Voice => Domain.Entities.Message.BuildVoice(ctx, command.Url, command.Duration ?? 0, sequenceId, command.FileId),
|
||||
|
||||
MessageType.File => Domain.Entities.Message.BuildFile(ctx, command.FileId!.Value, command.Url,
|
||||
command.FileName!, command.FileSize!.Value, command.FileFormat!, sequenceId),
|
||||
|
||||
_ => null
|
||||
};
|
||||
@@ -109,6 +112,11 @@ namespace MessageService.WebApi.Application.Message
|
||||
|
||||
public async Task<Result<GetMessagesResponse>> GetMessagesAsync(GetMessageCommand command)
|
||||
{
|
||||
if (command.direction is not 0 and not 1 || command.limit is < 1 or > 100)
|
||||
{
|
||||
return Result.Fail<GetMessagesResponse>(ResultCode.PARAMETER_ERROR);
|
||||
}
|
||||
|
||||
var conversation = await conversationReposity.FindByIdAsync(command.conversationId);
|
||||
|
||||
if(conversation is null || conversation.UserId != command.userId)
|
||||
|
||||
@@ -22,8 +22,12 @@ namespace MessageService.WebApi.Application.Message
|
||||
public int? Height { get; init; }
|
||||
public string? Thumb { get; init; }
|
||||
public int? Duration { get; init; }
|
||||
public Guid? FileId { get; init; }
|
||||
public string? FileName { get; init; }
|
||||
public long? FileSize { get; init; }
|
||||
public string? FileFormat { get; init; }
|
||||
|
||||
public SendMsgCommand(Guid senderId, Guid targetId, ChatType chatType, MessageType msgType, Guid clientMsgId, Guid? quoteMessageId, Dictionary<string, string>? ext, string? text, string? url, int? width, int? height, string? thumb, int? duration)
|
||||
public SendMsgCommand(Guid senderId, Guid targetId, ChatType chatType, MessageType msgType, Guid clientMsgId, Guid? quoteMessageId, Dictionary<string, string>? ext, string? text, string? url, int? width, int? height, string? thumb, int? duration, Guid? fileId, string? fileName, long? fileSize, string? fileFormat)
|
||||
{
|
||||
SenderId = senderId;
|
||||
TargetId = targetId;
|
||||
@@ -38,6 +42,10 @@ namespace MessageService.WebApi.Application.Message
|
||||
Height = height;
|
||||
Thumb = thumb;
|
||||
Duration = duration;
|
||||
FileId = fileId;
|
||||
FileName = fileName;
|
||||
FileSize = fileSize;
|
||||
FileFormat = fileFormat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user