summaryrefslogtreecommitdiff
path: root/internal/processing/fromclientapi.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-06-21 15:56:00 +0200
committerLibravatar GitHub <noreply@github.com>2021-06-21 15:56:00 +0200
commita5fd6f427bab2cac03b4da5668eed18b900ba3be (patch)
tree5456928a707656a54cddcffb1199f59a4bc9039e /internal/processing/fromclientapi.go
parentTestrig fixes (#50) (diff)
downloadgotosocial-a5fd6f427bab2cac03b4da5668eed18b900ba3be.tar.xz
Deletes+unboosts (#52)
* Status deletes properly streamed now. * Unboosts now work locally and federated. * Documentation updates.
Diffstat (limited to 'internal/processing/fromclientapi.go')
-rw-r--r--internal/processing/fromclientapi.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/internal/processing/fromclientapi.go b/internal/processing/fromclientapi.go
index 8c4a1692e..180af04fe 100644
--- a/internal/processing/fromclientapi.go
+++ b/internal/processing/fromclientapi.go
@@ -138,6 +138,18 @@ func (p *processor) processFromClientAPI(clientMsg gtsmodel.FromClientAPI) error
return errors.New("undo was not parseable as *gtsmodel.StatusFave")
}
return p.federateUnfave(fave, clientMsg.OriginAccount, clientMsg.TargetAccount)
+ case gtsmodel.ActivityStreamsAnnounce:
+ // UNDO ANNOUNCE/BOOST
+ boost, ok := clientMsg.GTSModel.(*gtsmodel.Status)
+ if !ok {
+ return errors.New("undo was not parseable as *gtsmodel.Status")
+ }
+
+ if err := p.deleteStatusFromTimelines(boost); err != nil {
+ return err
+ }
+
+ return p.federateUnannounce(boost, clientMsg.OriginAccount, clientMsg.TargetAccount)
}
case gtsmodel.ActivityStreamsDelete:
// DELETE
@@ -313,6 +325,36 @@ func (p *processor) federateUnfave(fave *gtsmodel.StatusFave, originAccount *gts
return err
}
+func (p *processor) federateUnannounce(boost *gtsmodel.Status, originAccount *gtsmodel.Account, targetAccount *gtsmodel.Account) error {
+ asAnnounce, err := p.tc.BoostToAS(boost, originAccount, targetAccount)
+ if err != nil {
+ return fmt.Errorf("federateUnannounce: error converting status to announce: %s", err)
+ }
+
+ // create an Undo and set the appropriate actor on it
+ undo := streams.NewActivityStreamsUndo()
+ undo.SetActivityStreamsActor(asAnnounce.GetActivityStreamsActor())
+
+ // Set the boost as the 'object' property.
+ undoObject := streams.NewActivityStreamsObjectProperty()
+ undoObject.AppendActivityStreamsAnnounce(asAnnounce)
+ undo.SetActivityStreamsObject(undoObject)
+
+ // set the to
+ undo.SetActivityStreamsTo(asAnnounce.GetActivityStreamsTo())
+
+ // set the cc
+ undo.SetActivityStreamsCc(asAnnounce.GetActivityStreamsCc())
+
+ outboxIRI, err := url.Parse(originAccount.OutboxURI)
+ if err != nil {
+ return fmt.Errorf("federateUnannounce: error parsing outboxURI %s: %s", originAccount.OutboxURI, err)
+ }
+
+ _, err = p.federator.FederatingActor().Send(context.Background(), outboxIRI, undo)
+ return err
+}
+
func (p *processor) federateAcceptFollowRequest(follow *gtsmodel.Follow, originAccount *gtsmodel.Account, targetAccount *gtsmodel.Account) error {
// if both accounts are local there's nothing to do here
if originAccount.Domain == "" && targetAccount.Domain == "" {