View Source Bonfire.Social.Feeds (Bonfire v0.9.11-social-beta.6)

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

feed_name()

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

Names a predefined feed attached to a user

Functions

admin_notifications(admin)

admins_notifications()

Retrieves the notifications feed IDs for all admins.

admins_notifications(admins)

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

feed_id(type, object)

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

feed_id!(feed_name, for_subject)

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

feed_ids(feed_name, for_subjects)

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]

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

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

feed_presets()

inbox_of_obj_creator(object)

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

maybe_create_feed(type, for_subject)

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}

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

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)
[]

maybe_custom_feeds(preset_and_custom_boundary)

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"]

maybe_my_outbox_feed_id(me, boundary)

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

my_feed_id(type, other)

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

my_home_feed_ids(socket_or_opts, extra_feeds \\ [])

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

named_feed_id(name, opts \\ [])

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

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

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

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

schema_module()

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

target_feeds(changeset, creator, opts)

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