diff options
Diffstat (limited to 'internal/processing')
-rw-r--r-- | internal/processing/account/createfollow.go | 18 | ||||
-rw-r--r-- | internal/processing/status/util.go | 20 |
2 files changed, 17 insertions, 21 deletions
diff --git a/internal/processing/account/createfollow.go b/internal/processing/account/createfollow.go index 50e575f19..e89db9d47 100644 --- a/internal/processing/account/createfollow.go +++ b/internal/processing/account/createfollow.go @@ -31,7 +31,7 @@ import ( func (p *processor) FollowCreate(requestingAccount *gtsmodel.Account, form *apimodel.AccountFollowRequest) (*apimodel.Relationship, gtserror.WithCode) { // if there's a block between the accounts we shouldn't create the request ofc - blocked, err := p.db.Blocked(requestingAccount.ID, form.TargetAccountID) + blocked, err := p.db.Blocked(requestingAccount.ID, form.ID) if err != nil { return nil, gtserror.NewErrorInternalError(err) } @@ -41,9 +41,9 @@ func (p *processor) FollowCreate(requestingAccount *gtsmodel.Account, form *apim // make sure the target account actually exists in our db targetAcct := >smodel.Account{} - if err := p.db.GetByID(form.TargetAccountID, targetAcct); err != nil { + if err := p.db.GetByID(form.ID, targetAcct); err != nil { if _, ok := err.(db.ErrNoEntries); ok { - return nil, gtserror.NewErrorNotFound(fmt.Errorf("accountfollowcreate: account %s not found in the db: %s", form.TargetAccountID, err)) + return nil, gtserror.NewErrorNotFound(fmt.Errorf("accountfollowcreate: account %s not found in the db: %s", form.ID, err)) } } @@ -54,7 +54,7 @@ func (p *processor) FollowCreate(requestingAccount *gtsmodel.Account, form *apim } if follows { // already follows so just return the relationship - return p.RelationshipGet(requestingAccount, form.TargetAccountID) + return p.RelationshipGet(requestingAccount, form.ID) } // check if a follow exists already @@ -64,7 +64,7 @@ func (p *processor) FollowCreate(requestingAccount *gtsmodel.Account, form *apim } if followRequested { // already follow requested so just return the relationship - return p.RelationshipGet(requestingAccount, form.TargetAccountID) + return p.RelationshipGet(requestingAccount, form.ID) } // make the follow request @@ -76,7 +76,7 @@ func (p *processor) FollowCreate(requestingAccount *gtsmodel.Account, form *apim fr := >smodel.FollowRequest{ ID: newFollowID, AccountID: requestingAccount.ID, - TargetAccountID: form.TargetAccountID, + TargetAccountID: form.ID, ShowReblogs: true, URI: util.GenerateURIForFollow(requestingAccount.Username, p.config.Protocol, p.config.Host, newFollowID), Notify: false, @@ -95,11 +95,11 @@ func (p *processor) FollowCreate(requestingAccount *gtsmodel.Account, form *apim // if it's a local account that's not locked we can just straight up accept the follow request if !targetAcct.Locked && targetAcct.Domain == "" { - if _, err := p.db.AcceptFollowRequest(requestingAccount.ID, form.TargetAccountID); err != nil { + if _, err := p.db.AcceptFollowRequest(requestingAccount.ID, form.ID); err != nil { return nil, gtserror.NewErrorInternalError(fmt.Errorf("accountfollowcreate: error accepting folow request for local unlocked account: %s", err)) } // return the new relationship - return p.RelationshipGet(requestingAccount, form.TargetAccountID) + return p.RelationshipGet(requestingAccount, form.ID) } // otherwise we leave the follow request as it is and we handle the rest of the process asynchronously @@ -112,5 +112,5 @@ func (p *processor) FollowCreate(requestingAccount *gtsmodel.Account, form *apim } // return whatever relationship results from this - return p.RelationshipGet(requestingAccount, form.TargetAccountID) + return p.RelationshipGet(requestingAccount, form.ID) } diff --git a/internal/processing/status/util.go b/internal/processing/status/util.go index f85e05478..31541ce71 100644 --- a/internal/processing/status/util.go +++ b/internal/processing/status/util.go @@ -21,22 +21,18 @@ func (p *processor) processVisibility(form *apimodel.AdvancedStatusCreateForm, a Likeable: true, } - var gtsBasicVis gtsmodel.Visibility - // Advanced takes priority if it's set. - // If it's not set, take whatever masto visibility is set. - // If *that's* not set either, then just take the account default. + var vis gtsmodel.Visibility + // If visibility isn't set on the form, then just take the account default. // If that's also not set, take the default for the whole instance. - if form.VisibilityAdvanced != nil { - gtsBasicVis = gtsmodel.Visibility(*form.VisibilityAdvanced) - } else if form.Visibility != "" { - gtsBasicVis = p.tc.MastoVisToVis(form.Visibility) + if form.Visibility != "" { + vis = p.tc.MastoVisToVis(form.Visibility) } else if accountDefaultVis != "" { - gtsBasicVis = accountDefaultVis + vis = accountDefaultVis } else { - gtsBasicVis = gtsmodel.VisibilityDefault + vis = gtsmodel.VisibilityDefault } - switch gtsBasicVis { + switch vis { case gtsmodel.VisibilityPublic: // for public, there's no need to change any of the advanced flags from true regardless of what the user filled out break @@ -82,7 +78,7 @@ func (p *processor) processVisibility(form *apimodel.AdvancedStatusCreateForm, a gtsAdvancedVis.Likeable = true } - status.Visibility = gtsBasicVis + status.Visibility = vis status.VisibilityAdvanced = gtsAdvancedVis return nil } |