View Source Bonfire.Me.Characters (Bonfire v0.9.10-classic-beta.156)

Shared helpers for character types (such as User or Category)

Context for Bonfire.Data.Identity.Character mixin, which has these fields:

  • username
  • username_hash: hashed username (used for preserving uniqueness incl. deleted usernames)
  • outbox: Feed of activities by the user
  • inbox: Feed of messages and other activities for the user
  • notifications: Feed of notifications for the user

Summary

Functions

Retrieves a character by username.

Returns the appropriate mention prefix for a character type.

Returns the canonical URL for a character.

Cleans a username by replacing forbidden characters with underscores.

Retrieves multiple characters by IDs.

Checks if a username hash is available.

Deletes a character by username hash.

Updates a character with the given attributes.

Checks if a username is available.

Functions

Retrieves a character by username.

Examples

> Bonfire.Me.Characters.by_username("username")
%Bonfire.Data.Identity.Character{}
Link to this function

changeset(char \\ %Character{}, params, profile \\ :local)

View Source
Link to this function

character_mention_prefix(object)

View Source

Returns the appropriate mention prefix for a character type.

Examples

iex> Bonfire.Me.Characters.character_mention_prefix(%Bonfire.Data.Identity.User{})
"@"
Link to this function

character_url(character)

View Source

Returns the canonical URL for a character.

Examples

iex> Bonfire.Me.Characters.character_url(%Bonfire.Data.Identity.Character{})
"http://example.com/character/username"
Link to this function

clean_username(username)

View Source

Cleans a username by replacing forbidden characters with underscores.

Examples

iex> Bonfire.Me.Characters.clean_username("invalid username!")
"invalid_username"
Link to this function

display_username(user, always_include_domain \\ false, is_local? \\ nil, prefix \\ nil)

View Source

Displays a username with optional domain and prefix.

Examples

iex> Bonfire.Me.Characters.display_username("username")
"@username"

iex> Bonfire.Me.Characters.display_username("username", true, true, "@")
"@username@domain.com"

Retrieves multiple characters by IDs.

Examples

> Bonfire.Me.Characters.get("id_or_username")
%Bonfire.Data.Identity.Character{}

> Bonfire.Me.Characters.get(["id1", "id2"])
{:ok, [%Bonfire.Data.Identity.Character{}, %Bonfire.Data.Identity.Character{}]}

Checks if a username hash is available.

Examples

iex> Bonfire.Me.Characters.hash_available?("hash")
true

Deletes a character by username hash.

Examples

> Bonfire.Me.Characters.hash_delete("hash")
Link to this function

indexing_object_format(obj)

View Source
Link to this function

remote_changeset(changeset, params)

View Source

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

Link to this function

update(character, attrs)

View Source

Updates a character with the given attributes.

Examples

> Bonfire.Me.Characters.update(%Bonfire.Data.Identity.Character{}, %{field: "value"})
{:ok, %Bonfire.Data.Identity.Character{}}
Link to this function

username_available?(username)

View Source

Checks if a username is available.

Examples

iex> Bonfire.Me.Characters.username_available?("non_existing_username")
true