View Source Bonfire.Boundaries.Blocks (Bonfire v0.9.10-classic-beta.169)
Handles blocking of users and instances
This module provides functions to block and unblock users or instances, check if a user or instance is blocked, and manage block lists. It also includes federation support for ActivityPub.
Summary
Functions
Handles incoming Block activities from ActivityPub federation.
Blocks, silences, or ghosts a user or instance.
Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0
.
Blocks a user or instance for everyone on the instance (for admin/mod use only).
Checks if a user or instance is blocked.
Lists blocked users or instances for a given block type and scope
Blocks a remote instance.
Converts provided block types (eg. :ghost
or :silence
) into a list of internal block types.
Unblocks a user or instance.
Unblocks all users or instances for a given block type and scope (only used for debugging purposes)
Functions
Handles incoming Block activities from ActivityPub federation.
Examples
iex> Bonfire.Boundaries.Blocks.ap_receive_activity(blocker, activity, blocked)
Blocks, silences, or ghosts a user or instance.
Block a user for current user
iex> Bonfire.Boundaries.Blocks.block(user, current_user: blocker)
{:ok, "Blocked"}
Block a user for everyone on the instance (as an admin/mod)
iex> Bonfire.Boundaries.Blocks.block(user, :instance_wide)
{:ok, "Blocked"}
Silence a user for current user
iex> Bonfire.Boundaries.Blocks.block(user, :silence, current_user: blocker)
{:ok, "Blocked"}
Silence a user for everyone on the instance (as an admin/mod)
iex> Bonfire.Boundaries.Blocks.block(user, :silence, :instance_wide)
{:ok, "Blocked"}
Ghost a user for current user
iex> Bonfire.Boundaries.Blocks.block(user, :ghost, current_user: blocker)
{:ok, "Blocked"}
Ghost a user for everyone on the instance (as an admin/mod)
iex> Bonfire.Boundaries.Blocks.block(user, :ghost, :instance_wide)
{:ok, "Blocked"}
Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0
.
Blocks a user or instance for everyone on the instance (for admin/mod use only).
Examples
iex> Bonfire.Boundaries.Blocks.instance_wide_block(user, :ghost)
{:ok, "Blocked"}
Checks if a user or instance is blocked.
Examples
iex> Bonfire.Boundaries.Blocks.is_blocked?(instance, :ghost, current_user: checker)
false
iex> Bonfire.Boundaries.Blocks.is_blocked?(user, :silence, :instance_wide)
true
Lists blocked users or instances for a given block type and scope
Examples
iex> Bonfire.Boundaries.Blocks.list(:ghost, :instance_wide)
[%{id: "123", type: :ghost}, %{id: "456", type: :ghost}]
iex> Bonfire.Boundaries.Blocks.list(:silence, current_user: user)
[%{id: "789", type: :silence}]
Blocks a remote instance.
Block for current user
iex> Bonfire.Boundaries.Blocks.remote_instance_block("example.com", :silence, current_user)
{:ok, "Blocked"}
Block for everyone on the instance (as an admin/mod)
iex> Bonfire.Boundaries.Blocks.remote_instance_block("example.com", :silence, :instance_wide)
{:ok, "Blocked"}
Converts provided block types (eg. :ghost
or :silence
) into a list of internal block types.
Examples
iex> Bonfire.Boundaries.Blocks.types_blocked([:ghost, :silence])
[:ghost_them, :silence_them]
iex> Bonfire.Boundaries.Blocks.types_blocked(:ghost)
[:ghost_them]
iex> Bonfire.Boundaries.Blocks.types_blocked(nil)
[:silence_them, :ghost_them]
Unblocks a user or instance.
Examples
iex> Bonfire.Boundaries.Blocks.unblock(user, :ghost, current_user: unblocker)
{:ok, "Unblocked"}
iex> Bonfire.Boundaries.Blocks.unblock(user, :silence, :instance_wide)
{:ok, "Unblocked"}
Unblocks all users or instances for a given block type and scope (only used for debugging purposes)
Examples
iex> Bonfire.Boundaries.Blocks.unblock_all(:ghost, :instance_wide)
{:ok, "All unblocked"}