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.

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

Converts provided block types (eg. :ghost or :silence) into a list of internal block types.

Unblocks all users or instances for a given block type and scope (only used for debugging purposes)

Functions

Link to this function

ap_receive_activity(blocker, activity, blocked)

View Source

Handles incoming Block activities from ActivityPub federation.

Examples

iex> Bonfire.Boundaries.Blocks.ap_receive_activity(blocker, activity, blocked)
Link to this function

block(user_or_instance_to_block, block_type \\ nil, scope)

View Source

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.

Link to this function

instance_wide_block(user_or_instance_to_block, block_type \\ nil)

View Source

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"}
Link to this function

instance_wide_circles(block_types)

View Source
Link to this function

is_blocked?(user_or_instance, block_type \\ :any, opts \\ [])

View Source

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}]
Link to this function

remote_instance_block(display_hostname, block_type, scope)

View Source

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]
Link to this function

unblock(user_or_instance_to_unblock, block_type \\ nil, scope)

View Source

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"}
Link to this function

unblock_all(block_type \\ nil, scope)

View Source

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"}
Link to this function

user_block_circles(current_user, block_type)

View Source