feat: 优化,改造通知模块
This commit is contained in:
@@ -32,6 +32,6 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Notice
|
||||
/// <summary>
|
||||
/// 消息创建时间
|
||||
/// </summary>
|
||||
public DateTime CreationTime { get; }
|
||||
public DateTime CreationTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,34 @@ namespace Yi.Framework.Bbs.Domain.Shared.Consts
|
||||
|
||||
public const string Privacy = "【私密】您无该主题权限,可联系作者申请开放";
|
||||
|
||||
public const string AgreeNotice = "您的主题[{0}]被[{1}]用户点赞!得到一致认可,发现宝藏内容!";
|
||||
|
||||
public const string CommentNotice = "您的主题[{0}]被[{1}]用户评论!评论内容:[{2}]";
|
||||
public const string AgreeNotice = """
|
||||
<div>
|
||||
<h3 class="title" style="color: #333; font-size: 18px; margin: 0 0 10px;">🍗 您的主题 [{0}] 被 [{1}] 用户点赞!</h3>
|
||||
<p class="link" style="color: #555;font-size: 16px;">
|
||||
点击前往主题地址:
|
||||
<a href="/article/{2}" target="_blank" style="color: #007BFF;text-decoration: none;">https://ccnetcore.com/article/{2}</a>
|
||||
</p>
|
||||
</div>
|
||||
""";
|
||||
public const string CommentNotice = """
|
||||
<div>
|
||||
<h3 class="title" style="color: #333; font-size: 18px; margin: 0 0 10px;">🍖 您的主题 [{0}] 被 [{1}] 用户评论!</h3>
|
||||
<p class="link" style="color: #555;font-size: 16px;">
|
||||
评论内容:[{2}]
|
||||
点击前往主题地址:
|
||||
<a href="/article/{3}" target="_blank" style="color: #007BFF;text-decoration: none;">https://ccnetcore.com/article/{3}</a>
|
||||
</p>
|
||||
</div>
|
||||
""";
|
||||
public const string CommentNoticeToReply= """
|
||||
<div>
|
||||
<h3 class="title" style="color: #333; font-size: 18px; margin: 0 0 10px;">🍖 您在主题 [{0}] 的评论被 [{1}] 用户回复!</h3>
|
||||
<p class="link" style="color: #555;font-size: 16px;">
|
||||
评论内容:[{2}]
|
||||
点击前往主题地址:
|
||||
<a href="/article/{3}" target="_blank" style="color: #007BFF;text-decoration: none;">https://ccnetcore.com/article/{3}</a>
|
||||
</p>
|
||||
</div>
|
||||
""";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Yi.Framework.Bbs.Domain.Entities
|
||||
/// <summary>
|
||||
/// 消息,支持html
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||
.Select((agree, discuss) =>
|
||||
new
|
||||
{
|
||||
DiscussId=discuss.Id,
|
||||
DiscussTitle = discuss.Title,
|
||||
DiscussCreatorId = discuss.CreatorId,
|
||||
})
|
||||
@@ -53,7 +54,7 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
//通知主题作者,有人点赞
|
||||
await _localEventBus.PublishAsync(new BbsNoticeEventArgs(discussAndAgreeDto.DiscussCreatorId!.Value, string.Format(DiscussConst.AgreeNotice, discussAndAgreeDto.DiscussTitle, agreeUser.UserName)), false);
|
||||
await _localEventBus.PublishAsync(new BbsNoticeEventArgs(discussAndAgreeDto.DiscussCreatorId!.Value, string.Format(DiscussConst.AgreeNotice, discussAndAgreeDto.DiscussTitle, agreeUser.UserName,discussAndAgreeDto.DiscussId)), false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||
public async Task HandleEventAsync(BbsNoticeEventArgs eventData)
|
||||
{
|
||||
//离线存储
|
||||
await _repository.InsertAsync(new BbsNoticeAggregateRoot(eventData.NoticeType, eventData.Message, eventData.AcceptUserId));
|
||||
var entity= await _repository.InsertReturnEntityAsync(new BbsNoticeAggregateRoot(eventData.NoticeType, eventData.Message, eventData.AcceptUserId));
|
||||
switch (eventData.NoticeType)
|
||||
{
|
||||
case Shared.Enums.NoticeTypeEnum.Personal:
|
||||
if (BbsNoticeHub.HubUserModels.TryGetValue(eventData.AcceptUserId.ToString(), out var hubUserModel))
|
||||
{
|
||||
_hubContext.Clients.Client(hubUserModel.ConnnectionId).SendAsync(NoticeTypeEnum.Personal.ToString(), eventData.Message);
|
||||
_hubContext.Clients.Client(hubUserModel.ConnnectionId).SendAsync(NoticeTypeEnum.Personal.ToString(), eventData.Message,entity.CreationTime);
|
||||
}
|
||||
break;
|
||||
case Shared.Enums.NoticeTypeEnum.Broadcast:
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||
.Select((dicuss, user) =>
|
||||
new
|
||||
{
|
||||
DiscussId = user.Id,
|
||||
DiscussUserId = user.Id,
|
||||
DiscussTitle = dicuss.Title,
|
||||
|
||||
})
|
||||
@@ -53,7 +53,10 @@ namespace Yi.Framework.Bbs.Domain.EventHandlers
|
||||
//截取30个长度
|
||||
var content = commentEntity.Content.Length >= 30 ? commentEntity.Content.Substring(0, 30)+"..." : commentEntity.Content;
|
||||
//通知主题作者,有人评论
|
||||
await _localEventBus.PublishAsync(new BbsNoticeEventArgs(disucssDto.DiscussId, string.Format(DiscussConst.CommentNotice, disucssDto.DiscussTitle, commentUser.UserName, content)), false);
|
||||
await _localEventBus.PublishAsync(new BbsNoticeEventArgs(disucssDto.DiscussUserId, string.Format(DiscussConst.CommentNotice, disucssDto.DiscussTitle, commentUser.UserName, content,commentEntity.DiscussId)), false);
|
||||
//通知回复者,有人评论
|
||||
await _localEventBus.PublishAsync(new BbsNoticeEventArgs(commentEntity.ParentId, string.Format(DiscussConst.CommentNotice, disucssDto.DiscussTitle, commentUser.UserName, content,commentEntity.DiscussId)), false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user