feat: Adds a webhook for when a user follows the stream (#4362)
* feat: Adds a webhook for when a user follow the stream Frontend: Adds a checkbox which renders only when social features are enabled. Backend: - Defines a new type for the event - Implements the webhook including unit testing - Fires the webhook inside the ApproveFollower handler * Removes unnecessary Type fiels from Events struct * refactor: renames SendUserFollowedEvent func to FediverseEngagementFollow and fixes linting errors * fix: fixes unit test to reflect removed Type field from FediverseEngagementFollowEvent * feat: fires webhook also when manual approvals are not required * chore: slight cleanup --------- Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
co-authored by
Gabe Kangas
parent
9cc58d14c3
commit
80850b15d0
@@ -0,0 +1,32 @@
|
||||
package webhooks
|
||||
|
||||
import (
|
||||
"github.com/owncast/owncast/activitypub/events"
|
||||
"github.com/owncast/owncast/activitypub/persistence"
|
||||
"github.com/owncast/owncast/models"
|
||||
)
|
||||
|
||||
// SendFediverseEventFollow will send a user followed event to webhook
|
||||
// destinations.
|
||||
func SendFediverseEngagementFollowEvent(iri string) {
|
||||
follower, err := persistence.GetFollower(iri)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
userFollowedEvent := events.FediverseEngagementFollowEvent{}
|
||||
userFollowedEvent.SetDefaults()
|
||||
userFollowedEvent.Name = follower.Name
|
||||
userFollowedEvent.Username = follower.Username
|
||||
userFollowedEvent.Image = follower.Image.String()
|
||||
|
||||
sendFediverseEngagementEventFollow(userFollowedEvent)
|
||||
}
|
||||
|
||||
func sendFediverseEngagementEventFollow(event events.FediverseEngagementFollowEvent) {
|
||||
webhookEvent := WebhookEvent{
|
||||
Type: models.FediverseEngagementFollow,
|
||||
EventData: event,
|
||||
}
|
||||
|
||||
SendEventToWebhooks(webhookEvent)
|
||||
}
|
||||
Reference in New Issue
Block a user