作者 yangfu

feat: 内容安全

... ... @@ -102,6 +102,7 @@ func HandlerSecurityContent(ctx context.Context, svcCtx *svc.ServiceContext, con
if status == domain.ReviewStatusPass {
show = int(domain.ArticleShowEnable)
}
mnl := NewMessageNoticeLogic(ctx, svcCtx)
if c.Type == domain.TypeArticle {
if article, err = svcCtx.ArticleRepository.FindOne(ctx, conn, c.Id); err != nil {
return fmt.Errorf("文章不存在")
... ... @@ -110,6 +111,9 @@ func HandlerSecurityContent(ctx context.Context, svcCtx *svc.ServiceContext, con
if _, err = svcCtx.ArticleRepository.UpdateWithVersion(ctx, conn, article); err != nil {
return err
}
if show == int(domain.ArticleShowIllegal) {
mnl.ArticleIllegal(conn, article.CompanyId, article.AuthorId, time.Unix(article.CreatedAt, 0).Format("2006-01-02 15:04"), article.Title)
}
} else if c.Type == domain.TypeComment {
if comment, err = svcCtx.ArticleCommentRepository.FindOne(ctx, conn, c.Id); err != nil {
return fmt.Errorf("评论不存在")
... ... @@ -118,6 +122,9 @@ func HandlerSecurityContent(ctx context.Context, svcCtx *svc.ServiceContext, con
if _, err = svcCtx.ArticleCommentRepository.UpdateWithVersion(ctx, conn, comment); err != nil {
return err
}
if show == int(domain.CommentShowIllegal) {
mnl.ArticleIllegal(conn, comment.CompanyId, comment.FromUserId, time.Unix(comment.CreatedAt, 0).Format("2006-01-02 15:04"), comment.Content)
}
}
return nil
}
... ...
package core
import (
"context"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
)
type MessageNotice struct {
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMessageNoticeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MessageNotice {
return &MessageNotice{
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MessageNotice) ArticleIllegal(conn transaction.Conn, companyId, at int64, createdTime, title string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeIllegal, "文本内容违规", fmt.Sprintf("你于%v发布的帖子[%v]含有违规信息,未通过审核,已被禁止发布。请自觉遵守相关规定,若有疑问,请咨询运营管理员了解详情。", createdTime, title))
}
// CommentIllegal 评论违规
func (l *MessageNotice) CommentIllegal(conn transaction.Conn, at int64, companyId int64, createdTime, title string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeIllegal, "文本内容违规", fmt.Sprintf("你于%v发布的评论[%v]含有违规信息,未通过审核,已被禁止发布。请自觉遵守相关规定,若有疑问,请咨询运营管理员了解详情。", createdTime, title))
}
func (l *MessageNotice) createMessage(conn transaction.Conn, companyId, at int64, msgType domain.MsgSystemType, title string, content string) (err error) {
var msg = &domain.MessageSystem{
Type: msgType,
CompanyId: companyId,
RecipientId: at,
Title: title,
Content: content,
}
msg, err = l.svcCtx.MessageSystemRepository.Insert(l.ctx, conn, msg)
return err
}
... ...
... ... @@ -62,6 +62,11 @@ func (l *MiniSystemLogic) ArticleDeleted(conn transaction.Conn, companyId, at in
return l.createMessage(conn, companyId, at, domain.MsgTypeDeleted, "帖子已删除", fmt.Sprintf("你于%v发布的帖子[%v]已被删除,如有疑问,请联系运营管理员了解详情。", createdTime, title))
}
// ArticleIllegal 帖子违规
func (l *MiniSystemLogic) ArticleIllegal(conn transaction.Conn, companyId, at int64, createdTime, title string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeDeleted, "文本内容违规", fmt.Sprintf("你于%v发布的帖子[%v]含有违规信息,未通过审核,已被禁止发布。请自觉遵守相关规定,若有疑问,请咨询运营管理员了解详情。", createdTime, title))
}
//// ArticleAuth 文章权限变更
//func (l *MiniSystemLogic) ArticleAuth(conn transaction.Conn, companyId, at int64, item string) (err error) {
// return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "权限变更", fmt.Sprintf("您的帖子[%s]可见权限已添加,如有疑问,请联系运营管理员了解详情。", item))
... ... @@ -92,6 +97,11 @@ func (l *MiniSystemLogic) AbnormalCommentHidden(conn transaction.Conn, companyId
return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论被隐藏", fmt.Sprintf("您的评论[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item))
}
// CommentIllegal 评论违规
func (l *MiniSystemLogic) CommentIllegal(conn transaction.Conn, at int64, companyId int64, createdTime, title string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeIllegal, "文本内容违规", fmt.Sprintf("你于%v发布的评论[%v]含有违规信息,未通过审核,已被禁止发布。请自觉遵守相关规定,若有疑问,请咨询运营管理员了解详情。", createdTime, title))
}
func (l *MiniSystemLogic) createMessage(conn transaction.Conn, companyId, at int64, msgType domain.MsgSystemType, title string, content string) (err error) {
var msg = &domain.MessageSystem{
Type: msgType,
... ...
... ... @@ -21,9 +21,10 @@ type MessageSystem struct {
type MsgSystemType int
const (
MsgTypeNormal MsgSystemType = 1 //1业务正常通知
MsgTypeAbnormal MsgSystemType = 2 //2业务异常通知
MsgTypeDeleted MsgSystemType = 3 //3帖子删除通知
MsgTypeNormal MsgSystemType = 1 //1 业务正常通知(帖子定性)
MsgTypeAbnormal MsgSystemType = 2 //2 业务异常通知(评论删除)
MsgTypeDeleted MsgSystemType = 3 //3 帖子删除通知(帖子删除)
MsgTypeIllegal MsgSystemType = 4 //4 内容违规
)
type MessageSystemRepository interface {
... ...