View Source Bonfire.Social.Feeds (Bonfire v0.9.10-classic-beta.169)

Helpers to create or query (though that's usually done through Bonfire.Social.FeedActivities) feeds.

This is the context for Bonfire.Data.Social.Feed, a virtual schema with just one field:

  • id

Summary

Types

Names a predefined feed attached to a user

Functions

Retrieves the notifications feed IDs for all admins.

Retrieves the notifications feed IDs for the provided admin(s).

Gets the feed ID for a given feed name and subject.

Gets the feed ID for a given feed name and subject, raising an error if not found.

Retrieves a list of feed IDs based on the feed name and subjects.

Determines the feed IDs to publish based on the provided parameters.

Gets the inbox feed ID of the creator of the given object.

Creates a feed for the given subject if it doesn't already exist.

Checks if a creator notification should be sent for a subject.

Retrieves custom feeds if specified in the options.

Returns the feed ID of the outbox depending on the boundary.

Retrieves the feed ID for a given type and subject.

Generates the home feed IDs for a user, including extra feeds if specified.

Gets the feed ID for a named feed.

Generates a list of notification feed IDs based on mentions and replies.

Determines the target feeds for a given changeset, creator, and options.

Types

@type feed_name() :: :inbox | :outbox | :notifications

Names a predefined feed attached to a user

Functions

Link to this function

admin_notifications(admin)

View Source

Retrieves the notifications feed IDs for all admins.

Link to this function

admins_notifications(admins)

View Source

Retrieves the notifications feed IDs for the provided admin(s).

Examples

For an admin:

> Bonfire.Social.Feeds.admin_notifications(admin)
# Notifications feed ID for the admin

For a list of admins:

> Bonfire.Social.Feeds.admins_notifications([admin1, admin2])
# List of notifications feed IDs for the admins

Gets the feed ID for a given feed name and subject.

Examples

For a character:

> Bonfire.Social.Feeds.feed_id(:notifications, character)
# Feed ID for notifications of the character

For a binary feed name:

> Bonfire.Social.Feeds.feed_id("notifications", subject)
# Feed ID for notifications
Link to this function

feed_id!(feed_name, for_subject)

View Source

Gets the feed ID for a given feed name and subject, raising an error if not found.

Examples

For a valid feed:

> Bonfire.Social.Feeds.feed_id!(:notifications, subject)
# Feed ID for notifications

For an invalid feed:

> Bonfire.Social.Feeds.feed_id!(:invalid, subject)
** (RuntimeError) Expected feed name and user or character, got :invalid
Link to this function

feed_ids(feed_name, for_subjects)

View Source

Retrieves a list of feed IDs based on the feed name and subjects.

Examples

For a list of subjects:

> Bonfire.Social.Feeds.feed_ids(:notifications, [subject1, subject2])
# List of notification feed IDs for the subjects

For a single subject:

> Bonfire.Social.Feeds.feed_ids(:notifications, subject)
[feed_id]
Link to this function

feed_ids_to_publish(me, boundary, assigns, notify_feeds \\ nil)

View Source

Determines the feed IDs to publish based on the provided parameters.

TODO: de-duplicate feed_ids_to_publish/4 and target_feeds/3

Examples

When called with the "admins" boundary:

iex> Bonfire.Social.Feeds.feed_ids_to_publish(nil, "admins", nil)
# List of admin feed IDS

When called with a different boundary and some optional feeds:

> Bonfire.Social.Feeds.feed_ids_to_publish(me, "public", %{reply_to: true}, [some_feed_id])
# List of feed IDs for the provided boundary
Link to this function

inbox_of_obj_creator(object)

View Source

Gets the inbox feed ID of the creator of the given object.

Examples

For an object:

> Bonfire.Social.Feeds.inbox_of_obj_creator(object)
# Inbox feed ID of the object's creator
Link to this function

maybe_create_feed(type, for_subject)

View Source

Creates a feed for the given subject if it doesn't already exist.

Examples

For a new feed:

> Bonfire.Social.Feeds.maybe_create_feed(:notifications, subject)
{:ok, feed_id}

For an existing feed:

> Bonfire.Social.Feeds.maybe_create_feed(:notifications, existing_subject)
{:ok, existing_feed_id}
Link to this function

maybe_creator_notification(subject, object_creator, opts \\ [])

View Source

Checks if a creator notification should be sent for a subject.

Examples

When creator is different:

> Bonfire.Social.Feeds.maybe_creator_notification(subject, other_creator)
[{:notifications, other_creator}]

When creator is the same:

> Bonfire.Social.Feeds.maybe_creator_notification(subject, subject)
[]
Link to this function

maybe_custom_feeds(preset_and_custom_boundary)

View Source

Retrieves custom feeds if specified in the options.

Examples

With custom feeds specified:

iex> Bonfire.Social.Feeds.maybe_custom_feeds(to_feeds: [custom_feed_id])
[custom_feed_id]
Link to this function

maybe_my_outbox_feed_id(me, boundary)

View Source

Returns the feed ID of the outbox depending on the boundary.

Examples

When the boundary is "public":

> Bonfire.Social.Feeds.maybe_my_outbox_feed_id(me, "public")
# Feed ID of the outbox

When the boundary is "mentions" or "admins":

> Bonfire.Social.Feeds.maybe_my_outbox_feed_id(me, "mentions")
nil

Retrieves the feed ID for a given type and subject.

Examples

For a user:

> Bonfire.Social.Feeds.my_feed_id(:notifications, user)
# Feed ID for notifications of the user
Link to this function

my_home_feed_ids(socket_or_opts, extra_feeds \\ [])

View Source

Generates the home feed IDs for a user, including extra feeds if specified.

Examples

With socket options and extra feeds:

> Bonfire.Social.Feeds.my_home_feed_ids(socket_or_opts, [extra_feed_id])
# List of home feed IDs including extra feeds

Without socket options:

> Bonfire.Social.Feeds.my_home_feed_ids(_, [extra_feed_id])
# List of home feed IDs including extra feeds
Link to this function

named_feed_id(name, opts \\ [])

View Source

Gets the feed ID for a named feed.

Examples

For an existing named feed:

iex> Bonfire.Social.Feeds.named_feed_id(:notifications, [])
# Feed ID for notifications

For a binary name:

iex> Bonfire.Social.Feeds.named_feed_id("notifications", [])
# Feed ID for notifications
Link to this function

reply_and_or_mentions_notifications_feeds(me, boundary, mentions, reply_to_creator, to_circles \\ [])

View Source

Generates a list of notification feed IDs based on mentions and replies.

Examples

When there are mentions and a reply to creator:

> Bonfire.Social.Feeds.reply_and_or_mentions_notifications_feeds(me, "public", ["mention1"], "creator_id")
# List of notification feed IDs

When no mentions and no reply to creator:

> Bonfire.Social.Feeds.reply_and_or_mentions_notifications_feeds(me, "local", [], nil)
# List of notification feed IDs for local boundary
Link to this function

reply_and_or_mentions_to_notify(me, boundary, mentions, reply_to_creator, to_circles \\ [])

View Source

Callback implementation for Bonfire.Common.QueryModule.schema_module/0.

Link to this function

target_feeds(changeset, creator, opts)

View Source

Determines the target feeds for a given changeset, creator, and options.

TODO: de-duplicate feed_ids_to_publish/4 and target_feeds/3

Examples

When given a changeset:

> Bonfire.Social.Feeds.target_feeds(changeset, creator, opts)
# List of target feed IDs based on the changeset

When given an object:

> Bonfire.Social.Feeds.target_feeds(object, creator, opts)
# List of target feed IDs based on the object