View Source Bonfire.Social.FeedActivities (Bonfire v0.9.11-social-beta.3)
Helpers to create or query a feed's activities.
This is the context for Bonfire.Data.Social.FeedPublish
, which has two foreign fields:
- id (of the activity, see
Bonfire.Social.Activities
) - feed (see
Bonfire.Social.Feeds
)
Summary
Functions
Casts the changeset to publish an activity to the given feed IDs.
Casts the changeset to publish an activity to the given creator and feed IDs.
Returns the total count of activities in feeds.
Remove activities from feeds, using specific filters
Remove one or more activities from all feeds
Gets a list of feed ids this activity was published to from the database.
Creates the underlying data for put_feed_publishes/2
.
Computes the feed ids for get_feed_publishes/2
.
Marks all unseen items in a feed as seen for the current user.
Creates a new local activity or takes an existing one and publishes to specified feeds
Creates a new local activity and publishes to appropriate feeds TODO: make this re-use the changeset-based code like in Epics instead of duplicating logic (currently it is only used in VF extension anyway)
Arranges for an insert changeset to also publish to feeds related to some objects.
Callback implementation for Bonfire.Common.ContextModule.query_module/0
.
Callback implementation for Bonfire.Common.ContextModule.schema_module/0
.
Returns the count of unseen items in a feed for the current user.
Functions
Casts the changeset to publish an activity to the given feed IDs.
Examples
> cast(changeset, feed_ids)
%Ecto.Changeset{}
Casts the changeset to publish an activity to the given creator and feed IDs.
Examples
> cast(changeset, creator, opts)
%Ecto.Changeset{}
Returns the total count of activities in feeds.
Remove activities from feeds, using specific filters
Examples
> filters = [object_id: "123"]
> Bonfire.Social.FeedActivities.delete(filters)
{5, nil}
Remove one or more activities from all feeds
Examples
> Bonfire.Social.FeedActivities.delete("123", :object_id)
{1, nil}
Gets a list of feed ids this activity was published to from the database.
Currently only used by the ActivityPub integration.
Examples
> feeds_for_activity(%{id: id})
[feed_id1, feed_id2]
> feeds_for_activity(id)
[feed_id1, feed_id2]
> feeds_for_activity(activity)
[]
Creates the underlying data for put_feed_publishes/2
.
Options: see get_publish_feed_ids/1
Examples
> options = [feeds: ["feed123", "feed456"]]
> Bonfire.Social.FeedActivities.get_feed_publishes(options)
[%{feed_id: "feed123"}, %{feed_id: "feed456"}]
Computes the feed ids for get_feed_publishes/2
.
Options:
:inbox
- list of users/characters whose inbox we should attempt to insert into.:outbox
- list of users/characters whose outbox we should attempt to insert into.:notifications
- list of users/characters whose notifications we should attempt to insert into.:feeds
- list of ids (or objects containing IDs) of feeds to post to.
Examples
> options = [outbox: [%{id: "author123"}], inbox: [%{id: "mention987"}], notifications: [%{id: "reply654"}], feeds: ["feed456"]]
> Bonfire.Social.FeedActivities.get_publish_feed_ids(options)
["inbox_feed_id_for_user123", "feed456"]
Marks all unseen items in a feed as seen for the current user.
Examples
> mark_all_seen(feed_id, current_user: me)
{:ok, number_of_marked_items}
Creates a new local activity or takes an existing one and publishes to specified feeds
Examples
> subject = %{id: "user123"}
> verb = :create
> object = %{id: "post456"}
> feeds = ["feed789"]
> opts = []
> Bonfire.Social.FeedActivities.maybe_feed_publish(subject, verb, object, feeds, opts)
{:ok, %Bonfire.Data.Social.Activity{}}
Creates a new local activity and publishes to appropriate feeds TODO: make this re-use the changeset-based code like in Epics instead of duplicating logic (currently it is only used in VF extension anyway)
Examples
> subject = %{id: "user123"}
> verb = :create
> object = %{id: "post456"}
> Bonfire.Social.FeedActivities.publish(subject, verb, object, [])
{:ok, %Bonfire.Data.Social.Activity{}}
Arranges for an insert changeset to also publish to feeds related to some objects.
Options: see get_publish_feed_ids/1
Examples
> changeset = %Ecto.Changeset{}
> options = [feeds: ["feed123", "feed456"]]
> Bonfire.Social.FeedActivities.put_feed_publishes(changeset, options)
%Ecto.Changeset{}
Callback implementation for Bonfire.Common.ContextModule.query_module/0
.
Callback implementation for Bonfire.Common.ContextModule.schema_module/0
.
Returns the count of unseen items in a feed for the current user.
Examples
> unseen_count(feed_id, current_user: me)
5