Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow creator to bypass blocking on their own content #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion helper/moderation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion server/services/v1/comments/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion server/services/v2/reactions/react.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down