diff options
author | 2023-10-04 13:09:42 +0100 | |
---|---|---|
committer | 2023-10-04 13:09:42 +0100 | |
commit | c6e00afc7c23df994b70eee89d2d392718e6a321 (patch) | |
tree | cee98c1a78e36ba6a0e8183afa0b2796765fe7f6 /internal/processing/workers/fromclientapi.go | |
parent | [chore] internal/ap: add pollable AS types, code reformatting, general niceti... (diff) | |
download | gotosocial-c6e00afc7c23df994b70eee89d2d392718e6a321.tar.xz |
[feature] tentatively start adding polls support (#2249)
Diffstat (limited to 'internal/processing/workers/fromclientapi.go')
-rw-r--r-- | internal/processing/workers/fromclientapi.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/internal/processing/workers/fromclientapi.go b/internal/processing/workers/fromclientapi.go index 1c668db71..ff316b1f4 100644 --- a/internal/processing/workers/fromclientapi.go +++ b/internal/processing/workers/fromclientapi.go @@ -114,6 +114,10 @@ func (p *Processor) ProcessFromClientAPI(ctx context.Context, cMsg messages.From case ap.ActivityUpdate: switch cMsg.APObjectType { + // UPDATE NOTE/STATUS + case ap.ObjectNote: + return p.clientAPI.UpdateStatus(ctx, cMsg) + // UPDATE PROFILE/ACCOUNT case ap.ObjectProfile, ap.ActorPerson: return p.clientAPI.UpdateAccount(ctx, cMsg) @@ -332,10 +336,25 @@ func (p *clientAPI) CreateBlock(ctx context.Context, cMsg messages.FromClientAPI return nil } +func (p *clientAPI) UpdateStatus(ctx context.Context, cMsg messages.FromClientAPI) error { + // Cast the updated Status model attached to msg. + status, ok := cMsg.GTSModel.(*gtsmodel.Status) + if !ok { + return gtserror.Newf("cannot cast %T -> *gtsmodel.Status", cMsg.GTSModel) + } + + // Federate the updated status changes out remotely. + if err := p.federate.UpdateStatus(ctx, status); err != nil { + return gtserror.Newf("error federating status update: %w", err) + } + + return nil +} + func (p *clientAPI) UpdateAccount(ctx context.Context, cMsg messages.FromClientAPI) error { account, ok := cMsg.GTSModel.(*gtsmodel.Account) if !ok { - return gtserror.Newf("%T not parseable as *gtsmodel.Account", cMsg.GTSModel) + return gtserror.Newf("cannot cast %T -> *gtsmodel.Account", cMsg.GTSModel) } if err := p.federate.UpdateAccount(ctx, account); err != nil { |