diff options
Diffstat (limited to 'internal/processing/account')
-rw-r--r-- | internal/processing/account/account.go | 5 | ||||
-rw-r--r-- | internal/processing/account/createblock.go | 20 | ||||
-rw-r--r-- | internal/processing/account/createfollow.go | 8 | ||||
-rw-r--r-- | internal/processing/account/delete.go | 19 | ||||
-rw-r--r-- | internal/processing/account/removeblock.go | 8 | ||||
-rw-r--r-- | internal/processing/account/removefollow.go | 14 | ||||
-rw-r--r-- | internal/processing/account/update.go | 18 |
7 files changed, 52 insertions, 40 deletions
diff --git a/internal/processing/account/account.go b/internal/processing/account/account.go index 81701fd7c..71b876d3b 100644 --- a/internal/processing/account/account.go +++ b/internal/processing/account/account.go @@ -30,6 +30,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/media" + "github.com/superseriousbusiness/gotosocial/internal/messages" "github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/gotosocial/internal/typeutils" "github.com/superseriousbusiness/gotosocial/internal/visibility" @@ -79,7 +80,7 @@ type processor struct { tc typeutils.TypeConverter config *config.Config mediaHandler media.Handler - fromClientAPI chan gtsmodel.FromClientAPI + fromClientAPI chan messages.FromClientAPI oauthServer oauth.Server filter visibility.Filter db db.DB @@ -88,7 +89,7 @@ type processor struct { } // New returns a new account processor. -func New(db db.DB, tc typeutils.TypeConverter, mediaHandler media.Handler, oauthServer oauth.Server, fromClientAPI chan gtsmodel.FromClientAPI, federator federation.Federator, config *config.Config, log *logrus.Logger) Processor { +func New(db db.DB, tc typeutils.TypeConverter, mediaHandler media.Handler, oauthServer oauth.Server, fromClientAPI chan messages.FromClientAPI, federator federation.Federator, config *config.Config, log *logrus.Logger) Processor { return &processor{ tc: tc, config: config, diff --git a/internal/processing/account/createblock.go b/internal/processing/account/createblock.go index 06f82b37d..347f19bee 100644 --- a/internal/processing/account/createblock.go +++ b/internal/processing/account/createblock.go @@ -22,11 +22,13 @@ import ( "context" "fmt" + "github.com/superseriousbusiness/gotosocial/internal/ap" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/id" + "github.com/superseriousbusiness/gotosocial/internal/messages" "github.com/superseriousbusiness/gotosocial/internal/util" ) @@ -111,9 +113,9 @@ func (p *processor) BlockCreate(ctx context.Context, requestingAccount *gtsmodel // follow request status changed so send the UNDO activity to the channel for async processing if frChanged { - p.fromClientAPI <- gtsmodel.FromClientAPI{ - APObjectType: gtsmodel.ActivityStreamsFollow, - APActivityType: gtsmodel.ActivityStreamsUndo, + p.fromClientAPI <- messages.FromClientAPI{ + APObjectType: ap.ActivityFollow, + APActivityType: ap.ActivityUndo, GTSModel: >smodel.Follow{ AccountID: requestingAccount.ID, TargetAccountID: targetAccountID, @@ -126,9 +128,9 @@ func (p *processor) BlockCreate(ctx context.Context, requestingAccount *gtsmodel // follow status changed so send the UNDO activity to the channel for async processing if fChanged { - p.fromClientAPI <- gtsmodel.FromClientAPI{ - APObjectType: gtsmodel.ActivityStreamsFollow, - APActivityType: gtsmodel.ActivityStreamsUndo, + p.fromClientAPI <- messages.FromClientAPI{ + APObjectType: ap.ActivityFollow, + APActivityType: ap.ActivityUndo, GTSModel: >smodel.Follow{ AccountID: requestingAccount.ID, TargetAccountID: targetAccountID, @@ -140,9 +142,9 @@ func (p *processor) BlockCreate(ctx context.Context, requestingAccount *gtsmodel } // handle the rest of the block process asynchronously - p.fromClientAPI <- gtsmodel.FromClientAPI{ - APObjectType: gtsmodel.ActivityStreamsBlock, - APActivityType: gtsmodel.ActivityStreamsCreate, + p.fromClientAPI <- messages.FromClientAPI{ + APObjectType: ap.ActivityBlock, + APActivityType: ap.ActivityCreate, GTSModel: block, OriginAccount: requestingAccount, TargetAccount: targetAccount, diff --git a/internal/processing/account/createfollow.go b/internal/processing/account/createfollow.go index a7767afea..d3ca386ed 100644 --- a/internal/processing/account/createfollow.go +++ b/internal/processing/account/createfollow.go @@ -22,11 +22,13 @@ import ( "context" "fmt" + "github.com/superseriousbusiness/gotosocial/internal/ap" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/id" + "github.com/superseriousbusiness/gotosocial/internal/messages" "github.com/superseriousbusiness/gotosocial/internal/util" ) @@ -99,9 +101,9 @@ func (p *processor) FollowCreate(ctx context.Context, requestingAccount *gtsmode } // otherwise we leave the follow request as it is and we handle the rest of the process asynchronously - p.fromClientAPI <- gtsmodel.FromClientAPI{ - APObjectType: gtsmodel.ActivityStreamsFollow, - APActivityType: gtsmodel.ActivityStreamsCreate, + p.fromClientAPI <- messages.FromClientAPI{ + APObjectType: ap.ActivityFollow, + APActivityType: ap.ActivityCreate, GTSModel: fr, OriginAccount: requestingAccount, TargetAccount: targetAcct, diff --git a/internal/processing/account/delete.go b/internal/processing/account/delete.go index d97af4d2e..5de706045 100644 --- a/internal/processing/account/delete.go +++ b/internal/processing/account/delete.go @@ -23,9 +23,10 @@ import ( "time" "github.com/sirupsen/logrus" + "github.com/superseriousbusiness/gotosocial/internal/ap" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" - "github.com/superseriousbusiness/gotosocial/internal/oauth" + "github.com/superseriousbusiness/gotosocial/internal/messages" ) // Delete handles the complete deletion of an account. @@ -64,12 +65,12 @@ func (p *processor) Delete(ctx context.Context, account *gtsmodel.Account, origi u := >smodel.User{} if err := p.db.GetWhere(ctx, []db.Where{{Key: "account_id", Value: account.ID}}, u); err == nil { // we got one! select all tokens with the user's ID - tokens := []*oauth.Token{} + tokens := []*gtsmodel.Token{} if err := p.db.GetWhere(ctx, []db.Where{{Key: "user_id", Value: u.ID}}, &tokens); err == nil { // we have some tokens to delete for _, t := range tokens { // delete client(s) associated with this token - if err := p.db.DeleteByID(ctx, t.ClientID, &oauth.Client{}); err != nil { + if err := p.db.DeleteByID(ctx, t.ClientID, >smodel.Client{}); err != nil { l.Errorf("error deleting oauth client: %s", err) } // delete application(s) associated with this token @@ -150,9 +151,9 @@ selectStatusesLoop: // pass the status delete through the client api channel for processing s.Account = account l.Debug("putting status in the client api channel") - p.fromClientAPI <- gtsmodel.FromClientAPI{ - APObjectType: gtsmodel.ActivityStreamsNote, - APActivityType: gtsmodel.ActivityStreamsDelete, + p.fromClientAPI <- messages.FromClientAPI{ + APObjectType: ap.ObjectNote, + APActivityType: ap.ActivityDelete, GTSModel: s, OriginAccount: account, TargetAccount: account, @@ -186,9 +187,9 @@ selectStatusesLoop: } l.Debug("putting boost undo in the client api channel") - p.fromClientAPI <- gtsmodel.FromClientAPI{ - APObjectType: gtsmodel.ActivityStreamsAnnounce, - APActivityType: gtsmodel.ActivityStreamsUndo, + p.fromClientAPI <- messages.FromClientAPI{ + APObjectType: ap.ActivityAnnounce, + APActivityType: ap.ActivityUndo, GTSModel: s, OriginAccount: b.Account, TargetAccount: account, diff --git a/internal/processing/account/removeblock.go b/internal/processing/account/removeblock.go index 7e3d78076..06bafb3a4 100644 --- a/internal/processing/account/removeblock.go +++ b/internal/processing/account/removeblock.go @@ -22,10 +22,12 @@ import ( "context" "fmt" + "github.com/superseriousbusiness/gotosocial/internal/ap" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" + "github.com/superseriousbusiness/gotosocial/internal/messages" ) func (p *processor) BlockRemove(ctx context.Context, requestingAccount *gtsmodel.Account, targetAccountID string) (*apimodel.Relationship, gtserror.WithCode) { @@ -52,9 +54,9 @@ func (p *processor) BlockRemove(ctx context.Context, requestingAccount *gtsmodel // block status changed so send the UNDO activity to the channel for async processing if blockChanged { - p.fromClientAPI <- gtsmodel.FromClientAPI{ - APObjectType: gtsmodel.ActivityStreamsBlock, - APActivityType: gtsmodel.ActivityStreamsUndo, + p.fromClientAPI <- messages.FromClientAPI{ + APObjectType: ap.ActivityBlock, + APActivityType: ap.ActivityUndo, GTSModel: block, OriginAccount: requestingAccount, TargetAccount: targetAccount, diff --git a/internal/processing/account/removefollow.go b/internal/processing/account/removefollow.go index 6186c550f..9791f2e54 100644 --- a/internal/processing/account/removefollow.go +++ b/internal/processing/account/removefollow.go @@ -22,10 +22,12 @@ import ( "context" "fmt" + "github.com/superseriousbusiness/gotosocial/internal/ap" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" + "github.com/superseriousbusiness/gotosocial/internal/messages" ) func (p *processor) FollowRemove(ctx context.Context, requestingAccount *gtsmodel.Account, targetAccountID string) (*apimodel.Relationship, gtserror.WithCode) { @@ -78,9 +80,9 @@ func (p *processor) FollowRemove(ctx context.Context, requestingAccount *gtsmode // follow request status changed so send the UNDO activity to the channel for async processing if frChanged { - p.fromClientAPI <- gtsmodel.FromClientAPI{ - APObjectType: gtsmodel.ActivityStreamsFollow, - APActivityType: gtsmodel.ActivityStreamsUndo, + p.fromClientAPI <- messages.FromClientAPI{ + APObjectType: ap.ActivityFollow, + APActivityType: ap.ActivityUndo, GTSModel: >smodel.Follow{ AccountID: requestingAccount.ID, TargetAccountID: targetAccountID, @@ -93,9 +95,9 @@ func (p *processor) FollowRemove(ctx context.Context, requestingAccount *gtsmode // follow status changed so send the UNDO activity to the channel for async processing if fChanged { - p.fromClientAPI <- gtsmodel.FromClientAPI{ - APObjectType: gtsmodel.ActivityStreamsFollow, - APActivityType: gtsmodel.ActivityStreamsUndo, + p.fromClientAPI <- messages.FromClientAPI{ + APObjectType: ap.ActivityFollow, + APActivityType: ap.ActivityUndo, GTSModel: >smodel.Follow{ AccountID: requestingAccount.ID, TargetAccountID: targetAccountID, diff --git a/internal/processing/account/update.go b/internal/processing/account/update.go index 99ccbf5a0..c0fee8e25 100644 --- a/internal/processing/account/update.go +++ b/internal/processing/account/update.go @@ -26,11 +26,13 @@ import ( "io" "mime/multipart" + "github.com/superseriousbusiness/gotosocial/internal/ap" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/media" + "github.com/superseriousbusiness/gotosocial/internal/messages" "github.com/superseriousbusiness/gotosocial/internal/text" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/validate" ) func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form *apimodel.UpdateCredentialsRequest) (*apimodel.Account, error) { @@ -49,7 +51,7 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form } if form.DisplayName != nil { - if err := util.ValidateDisplayName(*form.DisplayName); err != nil { + if err := validate.DisplayName(*form.DisplayName); err != nil { return nil, err } displayName := text.RemoveHTML(*form.DisplayName) // no html allowed in display name @@ -59,7 +61,7 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form } if form.Note != nil { - if err := util.ValidateNote(*form.Note); err != nil { + if err := validate.Note(*form.Note); err != nil { return nil, err } note := text.SanitizeHTML(*form.Note) // html OK in note but sanitize it @@ -92,7 +94,7 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form if form.Source != nil { if form.Source.Language != nil { - if err := util.ValidateLanguage(*form.Source.Language); err != nil { + if err := validate.Language(*form.Source.Language); err != nil { return nil, err } if err := p.db.UpdateOneByID(ctx, account.ID, "language", *form.Source.Language, >smodel.Account{}); err != nil { @@ -107,7 +109,7 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form } if form.Source.Privacy != nil { - if err := util.ValidatePrivacy(*form.Source.Privacy); err != nil { + if err := validate.Privacy(*form.Source.Privacy); err != nil { return nil, err } if err := p.db.UpdateOneByID(ctx, account.ID, "privacy", *form.Source.Privacy, >smodel.Account{}); err != nil { @@ -122,9 +124,9 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form return nil, fmt.Errorf("could not fetch updated account %s: %s", account.ID, err) } - p.fromClientAPI <- gtsmodel.FromClientAPI{ - APObjectType: gtsmodel.ActivityStreamsProfile, - APActivityType: gtsmodel.ActivityStreamsUpdate, + p.fromClientAPI <- messages.FromClientAPI{ + APObjectType: ap.ObjectProfile, + APActivityType: ap.ActivityUpdate, GTSModel: updatedAccount, OriginAccount: updatedAccount, } |