This hook wraps a standard Misago function used to hide a ThreadUpdate object.
This hook can be imported from misago.threadupdates.hooks:
from misago.threadupdates.hooks import hide_thread_update_hookdef custom_hide_thread_update_filter(
action: HideThreadUpdateHookAction,
thread_update: 'ThreadUpdate',
request: HttpRequest | None=None,
) -> bool:
...A function implemented by a plugin that can be registered in this hook.
Misago function used to hide a ThreadUpdate object.
A ThreadUpdate instance to hide.
The request object or None if not available.
True if the thread update was hidden, False otherwise.
def hide_thread_update_action(
thread_update: 'ThreadUpdate', request: HttpRequest | None=None
) -> bool:
...Misago function used to hide a ThreadUpdate object.
A ThreadUpdate instance to hide.
The request object or None if not available.
True if the thread update was hidden, False otherwise.
The code below implements a custom filter function that stores the client's IP address when a thread update is hidden:
from django.http import HttpRequest
from misago.threads.hooks import hide_thread_update_hook
from misago.threads.models import ThreadUpdate
@hide_thread_update_hook.append_filter
def save_client_ip_on_thread_update_hide(
action,
thread_update: ThreadUpdate,
request: HttpRequest | None = None,
) -> bool:
if not request:
return action(thread_update)
thread_update.plugin_data["last_ip"] = request.client_ip
return action(thread_update, request)