Merge branch 'master' of https://gitea.nxsir.cn/nanxun/IM_NEW
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using MessageService.WebApi.Application.Conversation;
|
||||
using IM.ASPNETCore;
|
||||
using MessageService.Infrastructure;
|
||||
using MessageService.WebApi.Application.Conversation;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
@@ -30,5 +32,13 @@ namespace MessageService.WebApi.Controllers.Conversation
|
||||
return Ok(await service.GetByIdAsync(id, Guid.Parse(userId)));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[UnitOfWork(typeof(MessageDbContext))]
|
||||
public async Task<IActionResult> MarkRead([FromQuery] Guid conversationId)
|
||||
{
|
||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
return Ok(await service.MarkAsReadAsync(conversationId, Guid.Parse(userId)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,19 @@ namespace MessageService.WebApi.Controllers.Message
|
||||
RuleFor(r => r.TargetId)
|
||||
.NotEmpty()
|
||||
.NotNull();
|
||||
|
||||
// 文本消息:text 必填
|
||||
When(r => r.MsgType == MessageType.Text, () =>
|
||||
{
|
||||
RuleFor(r => r.Text).NotEmpty().WithMessage("文本消息的 text 字段不能为空");
|
||||
});
|
||||
|
||||
// 图片/视频/语音消息:url 必填
|
||||
When(r => r.MsgType == MessageType.Image || r.MsgType == MessageType.Video
|
||||
|| r.MsgType == MessageType.Voice || r.MsgType == MessageType.File, () =>
|
||||
{
|
||||
RuleFor(r => r.Url).NotEmpty().WithMessage("媒体消息的 url 字段不能为空");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user