mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[bugfix] Add Actor to outgoing poll vote Create; other fixes (#2384)
This commit is contained in:
@ -19,7 +19,6 @@ package typeutils
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/superseriousbusiness/activity/pub"
|
||||
"github.com/superseriousbusiness/activity/streams"
|
||||
@ -91,43 +90,6 @@ func WrapStatusableInCreate(status ap.Statusable, iriOnly bool) vocab.ActivitySt
|
||||
return create
|
||||
}
|
||||
|
||||
func WrapPollOptionablesInCreate(options ...ap.PollOptionable) vocab.ActivityStreamsCreate {
|
||||
if len(options) == 0 {
|
||||
panic("no options")
|
||||
}
|
||||
|
||||
// Extract attributedTo IRI from any option.
|
||||
attribTos := ap.GetAttributedTo(options[0])
|
||||
if len(attribTos) != 1 {
|
||||
panic("invalid attributedTo count")
|
||||
}
|
||||
|
||||
// Extract target status IRI from any option.
|
||||
replyTos := ap.GetInReplyTo(options[0])
|
||||
if len(replyTos) != 1 {
|
||||
panic("invalid inReplyTo count")
|
||||
}
|
||||
|
||||
// Allocate create activity and copy over 'To' property.
|
||||
create := streams.NewActivityStreamsCreate()
|
||||
ap.AppendTo(create, ap.GetTo(options[0])...)
|
||||
|
||||
// Activity ID formatted as: {$statusIRI}/activity#vote/{$voterIRI}.
|
||||
id := replyTos[0].String() + "/activity#vote/" + attribTos[0].String()
|
||||
ap.MustSet(ap.SetJSONLDIdStr, ap.WithJSONLDId(create), id)
|
||||
|
||||
// Set a current publish time for activity.
|
||||
ap.SetPublished(create, time.Now())
|
||||
|
||||
// Append each poll option as object to activity.
|
||||
for _, option := range options {
|
||||
status, _ := ap.ToStatusable(option)
|
||||
appendStatusableToActivity(create, status, false)
|
||||
}
|
||||
|
||||
return create
|
||||
}
|
||||
|
||||
func WrapStatusableInUpdate(status ap.Statusable, iriOnly bool) vocab.ActivityStreamsUpdate {
|
||||
update := streams.NewActivityStreamsUpdate()
|
||||
wrapStatusableInActivity(update, status, iriOnly)
|
||||
|
Reference in New Issue
Block a user