Streamex v0.3.0 Streamex.Feed

The Streamex.Feed module defines functions for working with feed followers.

Summary

Functions

Make source feed follow target feed. Returns {:ok, nil}, or {:error, message} if something went wrong

Make multiple sources follow multiple targets. Accepts a list of {source, target} feeds. Returns {:ok, nil}, or {:error, message} if something went wrong

Lists the given feed’s followers. Returns {:ok, followers}, or {:error, message} if something went wrong

Lists the feeds the given feed is following. Returns {:ok, following}, or {:error, message} if something went wrong

Initializes a new feed. Both slug and user_id must contain only alphanumeric characters. Returns {:ok, feed}, or {:error, message} if feed is invalid

Stop source feed from following target feed. Returns {:ok, nil}, or {:error, message} if something went wrong

Types

t :: %Streamex.Feed{id: term, slug: term, user_id: term}

Functions

follow(source, target, opts \\ [])

Make source feed follow target feed. Returns {:ok, nil}, or {:error, message} if something went wrong.

Available options are:

  • activity_copy_limit - how many activities should be copied from the target feed. Defaults to 300

Examples

iex> {_, source} = Streamex.Feed.new("user", "eric")
{:ok, %Streamex.Feed{...}}

iex> {_, target} = Streamex.Feed.new("user", "jessica")
{:ok, %Streamex.Feed{...}}

iex> Feed.follow(source, target)
{:ok, nil}
follow_many(feeds, opts \\ [])

Make multiple sources follow multiple targets. Accepts a list of {source, target} feeds. Returns {:ok, nil}, or {:error, message} if something went wrong.

Available options are:

  • activity_copy_limit - how many activities should be copied from the target feed. Defaults to 100

Examples

iex> {_, source} = Streamex.Feed.new("user", "eric")
{:ok, %Streamex.Feed{...}}

iex> {_, target} = Streamex.Feed.new("user", "jessica")
{:ok, %Streamex.Feed{...}}

iex> Feed.follow_many([{source, target}, ...])
{:ok, nil}
followers(feed, opts \\ [])

Lists the given feed’s followers. Returns {:ok, followers}, or {:error, message} if something went wrong.

Available options are:

  • limit - limits the number of results. Defaults to 25
  • offset - offsets the results. The maximum amount is 400

Examples

iex> Feed.followers(feed)
{:ok, [%Streamex.Follow{}...]}
following(feed, opts \\ [])

Lists the feeds the given feed is following. Returns {:ok, following}, or {:error, message} if something went wrong.

Available options are:

  • limit - limits the number of results. Defaults to 25
  • offset - offsets the results. The maximum amount is 400
  • filter - list of comma separated feed ids to filter on

Examples

iex> Feed.following(feed)
{:ok, [%Streamex.Follow{}...]}
new(slug, user_id)

Initializes a new feed. Both slug and user_id must contain only alphanumeric characters. Returns {:ok, feed}, or {:error, message} if feed is invalid.

Examples

iex > Streamex.Feed.new("user", "eric")
{:ok, %Streamex.Feed{...}}

iex > Streamex.Feed.new("user_", "eric")
{:error, "..."}
unfollow(source, target, opts \\ [])

Stop source feed from following target feed. Returns {:ok, nil}, or {:error, message} if something went wrong.

Available options are:

  • keep_history - if true activities from target won’t be removed from source

Examples

iex> {_, source} = Streamex.Feed.new("user", "eric")
{:ok, %Streamex.Feed{...}}

iex> {_, target} = Streamex.Feed.new("user", "jessica")
{:ok, %Streamex.Feed{...}}

iex> Feed.unfollow(source, target)
{:ok, nil}