View Source Bonfire.Me.Characters (Bonfire v0.9.10-classic-beta.169)
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.
Displays a username with optional domain and prefix.
Retrieves multiple characters by IDs.
Checks if a username hash is available.
Deletes a character by username hash.
Callback implementation for Bonfire.Common.QueryModule.schema_module/0
.
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{}
Returns the appropriate mention prefix for a character type.
Examples
iex> Bonfire.Me.Characters.character_mention_prefix(%Bonfire.Data.Identity.User{})
"@"
Returns the canonical URL for a character.
Examples
iex> Bonfire.Me.Characters.character_url(%Bonfire.Data.Identity.Character{})
"http://example.com/character/username"
Cleans a username by replacing forbidden characters with underscores.
Examples
iex> Bonfire.Me.Characters.clean_username("invalid username!")
"invalid_username"
display_username(user, always_include_domain \\ false, is_local? \\ nil, prefix \\ nil)
View SourceDisplays 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")
Callback implementation for Bonfire.Common.QueryModule.schema_module/0
.
Updates a character with the given attributes.
Examples
> Bonfire.Me.Characters.update(%Bonfire.Data.Identity.Character{}, %{field: "value"})
{:ok, %Bonfire.Data.Identity.Character{}}
Checks if a username is available.
Examples
iex> Bonfire.Me.Characters.username_available?("non_existing_username")
true