|
|
|
@ -49,7 +49,7 @@ func (s *privSrv) Chain() gin.HandlersChain {
|
|
|
|
|
func (s *privSrv) ThumbsDownTweetReply(req *web.TweetReplyThumbsReq) mir.Error {
|
|
|
|
|
if err := s.Ds.ThumbsDownReply(req.Uid, req.TweetId, req.CommentId, req.ReplyId); err != nil {
|
|
|
|
|
logrus.Errorf("thumbs down tweet reply error: %s req:%v", err, req)
|
|
|
|
|
return _errThumbsDownTweetReply
|
|
|
|
|
return web.ErrThumbsDownTweetReply
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
@ -57,7 +57,7 @@ func (s *privSrv) ThumbsDownTweetReply(req *web.TweetReplyThumbsReq) mir.Error {
|
|
|
|
|
func (s *privSrv) ThumbsUpTweetReply(req *web.TweetReplyThumbsReq) mir.Error {
|
|
|
|
|
if err := s.Ds.ThumbsUpReply(req.Uid, req.TweetId, req.CommentId, req.ReplyId); err != nil {
|
|
|
|
|
logrus.Errorf("thumbs up tweet reply error: %s req:%v", err, req)
|
|
|
|
|
return _errThumbsUpTweetReply
|
|
|
|
|
return web.ErrThumbsUpTweetReply
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
@ -65,7 +65,7 @@ func (s *privSrv) ThumbsUpTweetReply(req *web.TweetReplyThumbsReq) mir.Error {
|
|
|
|
|
func (s *privSrv) ThumbsDownTweetComment(req *web.TweetCommentThumbsReq) mir.Error {
|
|
|
|
|
if err := s.Ds.ThumbsDownComment(req.Uid, req.TweetId, req.CommentId); err != nil {
|
|
|
|
|
logrus.Errorf("thumbs down tweet comment error: %s req:%v", err, req)
|
|
|
|
|
return _errThumbsDownTweetComment
|
|
|
|
|
return web.ErrThumbsDownTweetComment
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
@ -73,7 +73,7 @@ func (s *privSrv) ThumbsDownTweetComment(req *web.TweetCommentThumbsReq) mir.Err
|
|
|
|
|
func (s *privSrv) ThumbsUpTweetComment(req *web.TweetCommentThumbsReq) mir.Error {
|
|
|
|
|
if err := s.Ds.ThumbsUpComment(req.Uid, req.TweetId, req.CommentId); err != nil {
|
|
|
|
|
logrus.Errorf("thumbs up tweet comment error: %s req:%v", err, req)
|
|
|
|
|
return _errThumbsUpTweetComment
|
|
|
|
|
return web.ErrThumbsUpTweetComment
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
@ -81,7 +81,7 @@ func (s *privSrv) ThumbsUpTweetComment(req *web.TweetCommentThumbsReq) mir.Error
|
|
|
|
|
func (s *privSrv) UnfollowTopic(req *web.UnfollowTopicReq) mir.Error {
|
|
|
|
|
if err := s.Ds.UnfollowTopic(req.Uid, req.TopicId); err != nil {
|
|
|
|
|
logrus.Errorf("user(%d) unfollow topic(%d) failed: %s", req.Uid, req.TopicId, err)
|
|
|
|
|
return _errUnfollowTopicFailed
|
|
|
|
|
return web.ErrUnfollowTopicFailed
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
@ -89,7 +89,7 @@ func (s *privSrv) UnfollowTopic(req *web.UnfollowTopicReq) mir.Error {
|
|
|
|
|
func (s *privSrv) FollowTopic(req *web.FollowTopicReq) mir.Error {
|
|
|
|
|
if err := s.Ds.FollowTopic(req.Uid, req.TopicId); err != nil {
|
|
|
|
|
logrus.Errorf("user(%d) follow topic(%d) failed: %s", req.Uid, req.TopicId, err)
|
|
|
|
|
return _errFollowTopicFailed
|
|
|
|
|
return web.ErrFollowTopicFailed
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
@ -98,7 +98,7 @@ func (s *privSrv) StickTopic(req *web.StickTopicReq) (*web.StickTopicResp, mir.E
|
|
|
|
|
status, err := s.Ds.StickTopic(req.Uid, req.TopicId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("user(%d) stick topic(%d) failed: %s", req.Uid, req.TopicId, err)
|
|
|
|
|
return nil, _errStickTopicFailed
|
|
|
|
|
return nil, web.ErrStickTopicFailed
|
|
|
|
|
}
|
|
|
|
|
return &web.StickTopicResp{
|
|
|
|
|
StickStatus: status,
|
|
|
|
@ -114,7 +114,7 @@ func (s *privSrv) UploadAttachment(req *web.UploadAttachmentReq) (*web.UploadAtt
|
|
|
|
|
objectUrl, err := s.oss.PutObject(ossSavePath, req.File, req.FileSize, req.ContentType, false)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("oss.putObject err: %s", err)
|
|
|
|
|
return nil, _errFileUploadFailed
|
|
|
|
|
return nil, web.ErrFileUploadFailed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 构造附件Model
|
|
|
|
@ -134,7 +134,7 @@ func (s *privSrv) UploadAttachment(req *web.UploadAttachmentReq) (*web.UploadAtt
|
|
|
|
|
attachment, err = s.Ds.CreateAttachment(attachment)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("Ds.CreateAttachment err: %s", err)
|
|
|
|
|
return nil, _errFileUploadFailed
|
|
|
|
|
return nil, web.ErrFileUploadFailed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &web.UploadAttachmentResp{
|
|
|
|
@ -151,14 +151,14 @@ func (s *privSrv) DownloadAttachmentPrecheck(req *web.DownloadAttachmentPrecheck
|
|
|
|
|
content, err := s.Ds.GetPostContentByID(req.ContentID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("Ds.GetPostContentByID err: %s", err)
|
|
|
|
|
return nil, _errInvalidDownloadReq
|
|
|
|
|
return nil, web.ErrInvalidDownloadReq
|
|
|
|
|
}
|
|
|
|
|
resp := &web.DownloadAttachmentPrecheckResp{Paid: true}
|
|
|
|
|
if content.Type == core.ContentTypeChargeAttachment {
|
|
|
|
|
tweet, err := s.GetTweetBy(content.PostID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("get tweet err: %v", err)
|
|
|
|
|
return nil, _errInvalidDownloadReq
|
|
|
|
|
return nil, web.ErrInvalidDownloadReq
|
|
|
|
|
}
|
|
|
|
|
// 发布者或管理员免费下载
|
|
|
|
|
if tweet.UserID == req.User.ID || req.User.IsAdmin {
|
|
|
|
@ -174,7 +174,7 @@ func (s *privSrv) DownloadAttachment(req *web.DownloadAttachmentReq) (*web.Downl
|
|
|
|
|
content, err := s.Ds.GetPostContentByID(req.ContentID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("s.GetPostContentByID err: %v", err)
|
|
|
|
|
return nil, _errInvalidDownloadReq
|
|
|
|
|
return nil, web.ErrInvalidDownloadReq
|
|
|
|
|
}
|
|
|
|
|
// 收费附件
|
|
|
|
|
if content.Type == core.ContentTypeChargeAttachment {
|
|
|
|
@ -207,7 +207,7 @@ func (s *privSrv) DownloadAttachment(req *web.DownloadAttachmentReq) (*web.Downl
|
|
|
|
|
signedURL, err := s.oss.SignURL(objectKey, 60)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("client.SignURL err: %v", err)
|
|
|
|
|
return nil, _errDownloadReqError
|
|
|
|
|
return nil, web.ErrDownloadReqError
|
|
|
|
|
}
|
|
|
|
|
return &web.DownloadAttachmentResp{
|
|
|
|
|
SignedURL: signedURL,
|
|
|
|
@ -224,7 +224,7 @@ func (s *privSrv) CreateTweet(req *web.CreateTweetReq) (_ *web.CreateTweetResp,
|
|
|
|
|
|
|
|
|
|
contents, err := persistMediaContents(s.oss, req.Contents)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, _errCreatePostFailed
|
|
|
|
|
return nil, web.ErrCreatePostFailed
|
|
|
|
|
}
|
|
|
|
|
mediaContents = contents
|
|
|
|
|
tags := tagsFrom(req.Tags)
|
|
|
|
@ -239,7 +239,7 @@ func (s *privSrv) CreateTweet(req *web.CreateTweetReq) (_ *web.CreateTweetResp,
|
|
|
|
|
post, err = s.Ds.CreatePost(post)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("Ds.CreatePost err: %s", err)
|
|
|
|
|
return nil, _errCreatePostFailed
|
|
|
|
|
return nil, web.ErrCreatePostFailed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建推文内容
|
|
|
|
@ -261,7 +261,7 @@ func (s *privSrv) CreateTweet(req *web.CreateTweetReq) (_ *web.CreateTweetResp,
|
|
|
|
|
}
|
|
|
|
|
if _, err = s.Ds.CreatePostContent(postContent); err != nil {
|
|
|
|
|
logrus.Infof("Ds.CreatePostContent err: %s", err)
|
|
|
|
|
return nil, _errCreateCommentFailed
|
|
|
|
|
return nil, web.ErrCreateCommentFailed
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -299,27 +299,27 @@ func (s *privSrv) CreateTweet(req *web.CreateTweetReq) (_ *web.CreateTweetResp,
|
|
|
|
|
formatedPosts, err := s.Ds.RevampPosts([]*core.PostFormated{post.Format()})
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Infof("Ds.RevampPosts err: %s", err)
|
|
|
|
|
return nil, _errCreatePostFailed
|
|
|
|
|
return nil, web.ErrCreatePostFailed
|
|
|
|
|
}
|
|
|
|
|
return (*web.CreateTweetResp)(formatedPosts[0]), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *privSrv) DeleteTweet(req *web.DeleteTweetReq) mir.Error {
|
|
|
|
|
if req.User == nil {
|
|
|
|
|
return _errNoPermission
|
|
|
|
|
return web.ErrNoPermission
|
|
|
|
|
}
|
|
|
|
|
post, err := s.Ds.GetPostByID(req.ID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("Ds.GetPostByID err: %s", err)
|
|
|
|
|
return _errGetPostFailed
|
|
|
|
|
return web.ErrGetPostFailed
|
|
|
|
|
}
|
|
|
|
|
if post.UserID != req.User.ID && !req.User.IsAdmin {
|
|
|
|
|
return _errNoPermission
|
|
|
|
|
return web.ErrNoPermission
|
|
|
|
|
}
|
|
|
|
|
mediaContents, err := s.Ds.DeletePost(post)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("Ds.DeletePost delete post failed: %s", err)
|
|
|
|
|
return _errDeletePostFailed
|
|
|
|
|
return web.ErrDeletePostFailed
|
|
|
|
|
}
|
|
|
|
|
// 删除推文的媒体内容
|
|
|
|
|
deleteOssObjects(s.oss, mediaContents)
|
|
|
|
@ -327,7 +327,7 @@ func (s *privSrv) DeleteTweet(req *web.DeleteTweetReq) mir.Error {
|
|
|
|
|
s.DeleteSearchPost(post)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("s.DeleteSearchPost failed: %s", err)
|
|
|
|
|
return _errDeletePostFailed
|
|
|
|
|
return web.ErrDeletePostFailed
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
@ -336,16 +336,16 @@ func (s *privSrv) DeleteCommentReply(req *web.DeleteCommentReplyReq) mir.Error {
|
|
|
|
|
reply, err := s.Ds.GetCommentReplyByID(req.ID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("Ds.GetCommentReplyByID err: %s", err)
|
|
|
|
|
return _errGetReplyFailed
|
|
|
|
|
return web.ErrGetReplyFailed
|
|
|
|
|
}
|
|
|
|
|
if req.User.ID != reply.UserID && !req.User.IsAdmin {
|
|
|
|
|
return _errNoPermission
|
|
|
|
|
return web.ErrNoPermission
|
|
|
|
|
}
|
|
|
|
|
// 执行删除
|
|
|
|
|
err = s.deletePostCommentReply(reply)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("s.deletePostCommentReply err: %s", err)
|
|
|
|
|
return _errDeleteCommentFailed
|
|
|
|
|
return web.ErrDeleteCommentFailed
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
@ -359,7 +359,7 @@ func (s *privSrv) CreateCommentReply(req *web.CreateCommentReplyReq) (*web.Creat
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if post, comment, atUserID, err = s.createPostPreHandler(req.CommentID, req.Uid, req.AtUserID); err != nil {
|
|
|
|
|
return nil, _errCreateReplyFailed
|
|
|
|
|
return nil, web.ErrCreateReplyFailed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建评论
|
|
|
|
@ -374,7 +374,7 @@ func (s *privSrv) CreateCommentReply(req *web.CreateCommentReplyReq) (*web.Creat
|
|
|
|
|
|
|
|
|
|
reply, err = s.Ds.CreateCommentReply(reply)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, _errCreateReplyFailed
|
|
|
|
|
return nil, web.ErrCreateReplyFailed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新Post回复数
|
|
|
|
@ -432,26 +432,26 @@ func (s *privSrv) DeleteComment(req *web.DeleteCommentReq) mir.Error {
|
|
|
|
|
comment, err := s.Ds.GetCommentByID(req.ID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("Ds.GetCommentByID err: %v\n", err)
|
|
|
|
|
return _errGetCommentFailed
|
|
|
|
|
return web.ErrGetCommentFailed
|
|
|
|
|
}
|
|
|
|
|
if req.User.ID != comment.UserID && !req.User.IsAdmin {
|
|
|
|
|
return _errNoPermission
|
|
|
|
|
return web.ErrNoPermission
|
|
|
|
|
}
|
|
|
|
|
// 加载post
|
|
|
|
|
post, err := s.Ds.GetPostByID(comment.PostID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return _errDeleteCommentFailed
|
|
|
|
|
return web.ErrDeleteCommentFailed
|
|
|
|
|
}
|
|
|
|
|
// 更新post回复数
|
|
|
|
|
post.CommentCount--
|
|
|
|
|
if err := s.Ds.UpdatePost(post); err != nil {
|
|
|
|
|
logrus.Errorf("Ds.UpdatePost err: %s", err)
|
|
|
|
|
return _errDeleteCommentFailed
|
|
|
|
|
return web.ErrDeleteCommentFailed
|
|
|
|
|
}
|
|
|
|
|
// TODO: 优化删除逻辑,事务化删除comment
|
|
|
|
|
if err := s.Ds.DeleteComment(comment); err != nil {
|
|
|
|
|
logrus.Errorf("Ds.DeleteComment err: %s", err)
|
|
|
|
|
return _errDeleteCommentFailed
|
|
|
|
|
return web.ErrDeleteCommentFailed
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
@ -478,7 +478,7 @@ func (s *privSrv) CreateComment(req *web.CreateCommentReq) (_ *web.CreateComment
|
|
|
|
|
return nil, xerror.ServerError
|
|
|
|
|
}
|
|
|
|
|
if post.CommentCount >= conf.AppSetting.MaxCommentCount {
|
|
|
|
|
return nil, _errMaxCommentCount
|
|
|
|
|
return nil, web.ErrMaxCommentCount
|
|
|
|
|
}
|
|
|
|
|
comment := &core.Comment{
|
|
|
|
|
PostID: post.ID,
|
|
|
|
@ -489,7 +489,7 @@ func (s *privSrv) CreateComment(req *web.CreateCommentReq) (_ *web.CreateComment
|
|
|
|
|
comment, err = s.Ds.CreateComment(comment)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("Ds.CreateComment err:%s", err)
|
|
|
|
|
return nil, _errCreateCommentFailed
|
|
|
|
|
return nil, web.ErrCreateCommentFailed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, item := range req.Contents {
|
|
|
|
@ -595,14 +595,14 @@ func (s *privSrv) VisibleTweet(req *web.VisibleTweetReq) (*web.VisibleTweetResp,
|
|
|
|
|
}
|
|
|
|
|
post, err := s.Ds.GetPostByID(req.ID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, _errVisblePostFailed
|
|
|
|
|
return nil, web.ErrVisblePostFailed
|
|
|
|
|
}
|
|
|
|
|
if xerr := checkPermision(req.User, post.UserID); xerr != nil {
|
|
|
|
|
return nil, xerr
|
|
|
|
|
}
|
|
|
|
|
if err = s.Ds.VisiblePost(post, req.Visibility); err != nil {
|
|
|
|
|
logrus.Warnf("s.Ds.VisiblePost: %s", err)
|
|
|
|
|
return nil, _errVisblePostFailed
|
|
|
|
|
return nil, web.ErrVisblePostFailed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 推送Search
|
|
|
|
@ -618,14 +618,14 @@ func (s *privSrv) StickTweet(req *web.StickTweetReq) (*web.StickTweetResp, mir.E
|
|
|
|
|
post, err := s.Ds.GetPostByID(req.ID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logrus.Errorf("Ds.GetPostByID err: %v\n", err)
|
|
|
|
|
return nil, _errStickPostFailed
|
|
|
|
|
return nil, web.ErrStickPostFailed
|
|
|
|
|
}
|
|
|
|
|
if !req.User.IsAdmin {
|
|
|
|
|
return nil, _errNoPermission
|
|
|
|
|
return nil, web.ErrNoPermission
|
|
|
|
|
}
|
|
|
|
|
newStatus := 1 - post.IsTop
|
|
|
|
|
if err = s.Ds.StickPost(post); err != nil {
|
|
|
|
|
return nil, _errStickPostFailed
|
|
|
|
|
return nil, web.ErrStickPostFailed
|
|
|
|
|
}
|
|
|
|
|
return &web.StickTweetResp{
|
|
|
|
|
StickStatus: newStatus,
|
|
|
|
@ -635,14 +635,14 @@ func (s *privSrv) StickTweet(req *web.StickTweetReq) (*web.StickTweetResp, mir.E
|
|
|
|
|
func (s *privSrv) LockTweet(req *web.LockTweetReq) (*web.LockTweetResp, mir.Error) {
|
|
|
|
|
post, err := s.Ds.GetPostByID(req.ID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, _errLockPostFailed
|
|
|
|
|
return nil, web.ErrLockPostFailed
|
|
|
|
|
}
|
|
|
|
|
if post.UserID != req.User.ID && !req.User.IsAdmin {
|
|
|
|
|
return nil, _errNoPermission
|
|
|
|
|
return nil, web.ErrNoPermission
|
|
|
|
|
}
|
|
|
|
|
newStatus := 1 - post.IsLock
|
|
|
|
|
if err := s.Ds.LockPost(post); err != nil {
|
|
|
|
|
return nil, _errLockPostFailed
|
|
|
|
|
return nil, web.ErrLockPostFailed
|
|
|
|
|
}
|
|
|
|
|
return &web.LockTweetResp{
|
|
|
|
|
LockStatus: newStatus,
|
|
|
|
@ -688,7 +688,7 @@ func (s *privSrv) createPostPreHandler(commentID int64, userID, atUserID int64)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if post.CommentCount >= conf.AppSetting.MaxCommentCount {
|
|
|
|
|
return nil, nil, atUserID, _errMaxCommentCount
|
|
|
|
|
return nil, nil, atUserID, web.ErrMaxCommentCount
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if userID == atUserID {
|
|
|
|
@ -715,7 +715,7 @@ func (s *privSrv) createPostStar(postID, userID int64) (*core.PostStar, mir.Erro
|
|
|
|
|
// 私密post不可操作
|
|
|
|
|
// TODO: 使用统一的permission checker来检查权限问题,这里好友可见post就没处理,是bug
|
|
|
|
|
if post.Visibility == core.PostVisitPrivate && post.UserID != userID {
|
|
|
|
|
return nil, _errNoPermission
|
|
|
|
|
return nil, web.ErrNoPermission
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
star, err := s.Ds.CreatePostStar(postID, userID)
|
|
|
|
@ -741,7 +741,7 @@ func (s *privSrv) deletePostStar(star *core.PostStar) mir.Error {
|
|
|
|
|
// 私密post特殊处理
|
|
|
|
|
// TODO: 使用统一的permission checker来检查权限问题,这里好友可见post就没处理,是bug
|
|
|
|
|
if post.Visibility == core.PostVisitPrivate && post.UserID != star.UserID {
|
|
|
|
|
return _errNoPermission
|
|
|
|
|
return web.ErrNoPermission
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err = s.Ds.DeletePostStar(star); err != nil {
|
|
|
|
@ -766,7 +766,7 @@ func (s *privSrv) createPostCollection(postID, userID int64) (*core.PostCollecti
|
|
|
|
|
// 私密post特殊处理
|
|
|
|
|
// TODO: 使用统一的permission checker来检查权限问题,这里好友可见post就没处理,是bug
|
|
|
|
|
if post.Visibility == core.PostVisitPrivate && post.UserID != userID {
|
|
|
|
|
return nil, _errNoPermission
|
|
|
|
|
return nil, web.ErrNoPermission
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
collection, err := s.Ds.CreatePostCollection(postID, userID)
|
|
|
|
@ -792,7 +792,7 @@ func (s *privSrv) deletePostCollection(collection *core.PostCollection) mir.Erro
|
|
|
|
|
// 私密post特殊处理
|
|
|
|
|
// TODO: 使用统一的permission checker来检查权限问题,这里好友可见post就没处理,是bug
|
|
|
|
|
if post.Visibility == core.PostVisitPrivate && post.UserID != collection.UserID {
|
|
|
|
|
return _errNoPermission
|
|
|
|
|
return web.ErrNoPermission
|
|
|
|
|
}
|
|
|
|
|
if err = s.Ds.DeletePostCollection(collection); err != nil {
|
|
|
|
|
return xerror.ServerError
|
|
|
|
@ -814,7 +814,7 @@ func (s *privSrv) checkPostAttachmentIsPaid(postID, userID int64) bool {
|
|
|
|
|
|
|
|
|
|
func (s *privSrv) buyPostAttachment(post *core.Post, user *core.User) mir.Error {
|
|
|
|
|
if user.Balance < post.AttachmentPrice {
|
|
|
|
|
return _errInsuffientDownloadMoney
|
|
|
|
|
return web.ErrInsuffientDownloadMoney
|
|
|
|
|
}
|
|
|
|
|
// 执行购买
|
|
|
|
|
if err := s.Ds.HandlePostAttachmentBought(post, user); err != nil {
|
|
|
|
|