-
-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87177d8
commit cb54324
Showing
7 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package typeutils | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
|
||
"github.com/go-fed/activity/streams" | ||
"github.com/go-fed/activity/streams/vocab" | ||
"github.com/google/uuid" | ||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" | ||
"github.com/superseriousbusiness/gotosocial/internal/util" | ||
) | ||
|
||
func (c *converter) WrapPersonInUpdate(person vocab.ActivityStreamsPerson, originAccount *gtsmodel.Account) (vocab.ActivityStreamsUpdate, error) { | ||
|
||
update := streams.NewActivityStreamsUpdate() | ||
|
||
// set the actor | ||
actorURI, err := url.Parse(originAccount.URI) | ||
if err != nil { | ||
return nil, fmt.Errorf("WrapPersonInUpdate: error parsing url %s: %s", originAccount.URI, err) | ||
} | ||
actorProp := streams.NewActivityStreamsActorProperty() | ||
actorProp.AppendIRI(actorURI) | ||
update.SetActivityStreamsActor(actorProp) | ||
|
||
// set the ID | ||
idString := util.GenerateURIForUpdate(originAccount.Username, c.config.Protocol, c.config.Host, uuid.NewString()) | ||
idURI, err := url.Parse(idString) | ||
if err != nil { | ||
return nil, fmt.Errorf("WrapPersonInUpdate: error parsing url %s: %s", idString, err) | ||
} | ||
idProp := streams.NewJSONLDIdProperty() | ||
idProp.SetIRI(idURI) | ||
update.SetJSONLDId(idProp) | ||
|
||
// set the person as the object here | ||
objectProp := streams.NewActivityStreamsObjectProperty() | ||
objectProp.AppendActivityStreamsPerson(person) | ||
update.SetActivityStreamsObject(objectProp) | ||
|
||
// to should be public | ||
toURI, err := url.Parse(asPublicURI) | ||
if err != nil { | ||
return nil, fmt.Errorf("WrapPersonInUpdate: error parsing url %s: %s", asPublicURI, err) | ||
} | ||
toProp := streams.NewActivityStreamsToProperty() | ||
toProp.AppendIRI(toURI) | ||
update.SetActivityStreamsTo(toProp) | ||
|
||
// bcc followers | ||
followersURI, err := url.Parse(originAccount.FollowersURI) | ||
if err != nil { | ||
return nil, fmt.Errorf("WrapPersonInUpdate: error parsing url %s: %s", originAccount.FollowersURI, err) | ||
} | ||
bccProp := streams.NewActivityStreamsBccProperty() | ||
bccProp.AppendIRI(followersURI) | ||
update.SetActivityStreamsBcc(bccProp) | ||
|
||
return update, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters