diff --git a/helper/moderation.go b/helper/moderation.go index 756e94d..c988852 100644 --- a/helper/moderation.go +++ b/helper/moderation.go @@ -12,13 +12,24 @@ import ( "github.com/lbryio/lbry.go/v2/extras/api" "github.com/lbryio/lbry.go/v2/extras/errors" + "github.com/lbryio/lbry.go/v2/extras/jsonrpc" "github.com/volatiletech/null/v8" "github.com/volatiletech/sqlboiler/v4/queries/qm" ) // AllowedToRespond checks if the creator of the comment will allow a response from the respondent -func AllowedToRespond(parentCommentID, commenterClaimID string) error { +func AllowedToRespond(parentCommentID, commenterClaimID, contentClaimID string, GetSigningChannelForClaim func(string) (*jsonrpc.Claim, error)) error { + contentCreatorChannel, err := GetSigningChannelForClaim(contentClaimID) + if err != nil { + return errors.Err(err) + } + if contentCreatorChannel != nil { + isCreator := commenterClaimID == contentCreatorChannel.ClaimID + if isCreator { + return nil + } + } parentComment, err := m.Comments(m.CommentWhere.CommentID.EQ(parentCommentID)).One(db.RO) if err != nil && !errors.Is(err, sql.ErrNoRows) { return errors.Err(err) diff --git a/server/services/v1/comments/create.go b/server/services/v1/comments/create.go index 88afc79..39b4f79 100644 --- a/server/services/v1/comments/create.go +++ b/server/services/v1/comments/create.go @@ -176,7 +176,7 @@ func checkAllowedAndValidate(request *createRequest) error { } if request.args.ParentID != nil { - err = helper.AllowedToRespond(util.StrFromPtr(request.args.ParentID), request.args.ChannelID) + err = helper.AllowedToRespond(util.StrFromPtr(request.args.ParentID), request.args.ChannelID, request.args.ClaimID, lbry.SDK.GetSigningChannelForClaim) if err != nil { return err } diff --git a/server/services/v2/reactions/react.go b/server/services/v2/reactions/react.go index aa44fea..6086de4 100644 --- a/server/services/v2/reactions/react.go +++ b/server/services/v2/reactions/react.go @@ -13,6 +13,7 @@ import ( "github.com/OdyseeTeam/commentron/helper" "github.com/OdyseeTeam/commentron/model" "github.com/OdyseeTeam/commentron/server/auth" + "github.com/OdyseeTeam/commentron/server/lbry" "github.com/OdyseeTeam/commentron/sockety" "github.com/OdyseeTeam/sockety/socketyapi" @@ -112,7 +113,7 @@ func updateReactions(channel *model.Channel, args *commentapi.ReactArgs, comment return errors.Err(err) } for _, p := range comments { - err = helper.AllowedToRespond(p.CommentID, channel.ClaimID) + err = helper.AllowedToRespond(p.CommentID, channel.ClaimID, p.LbryClaimID, lbry.SDK.GetSigningChannelForClaim) if err != nil { return err }