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

Track seen/unseen status of things (usually Activities).

This module implements functionality to manage the seen/unseen status of objects (similar to read/unread status in other apps, but only indicates that it was displayed in a feed or other listing for the user, not that they actually read it).

Seen is implemented on top of the Bonfire.Data.Edges.Edge schema (see Bonfire.Social.Edges for shared functions).

Summary

Functions

Retrieves a Seen edge between a subject and an object.

Similar to get/3, but raises an error if the Seen edge is not found.

Marks an object as seen by a user.

Marks an object as unseen by a user.

Creates a query for Seen edges based on the given filters and options.

Checks if a user has seen an object.

Functions

Link to this function

get(subject, object, opts \\ [])

View Source

Retrieves a Seen edge between a subject and an object.

Parameters

  • subject: The subject (usually a user) of the Seen edge.
  • object: The object that was seen.
  • opts: Additional options for the query (optional).

Examples

iex> subject = %User{id: "user123"}
iex> object = %Post{id: "post456"}
iex> Bonfire.Social.Seen.get(subject, object)
{:ok, %Seen{}}
Link to this function

get!(subject, object, opts \\ [])

View Source

Similar to get/3, but raises an error if the Seen edge is not found.

Link to this function

mark_seen(subject, object)

View Source

Marks an object as seen by a user.

Parameters

  • subject: The user marking the object as seen.
  • object: The object(s) or ID(s) being marked as seen.

Examples

iex> user = %User{id: "user123"}
iex> object = %Post{id: "post456"}
iex> Bonfire.Social.Seen.mark_seen(user, object)
{:ok, %Seen{}}

iex> Bonfire.Social.Seen.mark_seen(user, "456")
{:ok, %Seen{}}
Link to this function

mark_unseen(subject, object)

View Source

Marks an object as unseen by a user.

Parameters

  • subject: The user marking the object as unseen.
  • object: The object or ID being marked as unseen.

Examples

iex> user = %User{id: "user123"} iex> object = %Post{id: "post456"} iex> Bonfire.Social.Seen.mark_unseen(user, object)

iex> Bonfire.Social.Seen.mark_unseen(user, "456")

Creates a query for Seen edges based on the given filters and options.

Parameters

  • filters: A keyword list of filters to apply to the query.
  • opts: Additional options for the query.

Examples

iex> filters = [subject: %User{id: "123"}]
iex> opts = [limit: 10]
iex> Bonfire.Social.Seen.query(filters, opts)
#Ecto.Query<...>

Callback implementation for Bonfire.Common.ContextModule.query_module/0.

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

Checks if a user has seen an object.

Parameters

  • user: The user to check.
  • object: The object to check if seen.

Examples

iex> user = %User{id: "user123"}
iex> object = %Post{id: "post456"}
iex> Bonfire.Social.Seen.seen?(user, object)
true