From c6e00afc7c23df994b70eee89d2d392718e6a321 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:09:42 +0100 Subject: [feature] tentatively start adding polls support (#2249) --- internal/processing/workers/fromclientapi.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'internal/processing/workers/fromclientapi.go') 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 { -- cgit v1.2.3