This hook wraps the standard function that Misago uses to save a new private thread reply to the database.
This hook can be imported from misago.posting.hooks:
from misago.posting.hooks import save_private_thread_reply_state_hookdef custom_save_private_thread_reply_state_filter(
action: SavePrivateThreadReplyStateHookAction,
request: HttpRequest,
state: 'PrivateThreadReplyState',
):
...A function implemented by a plugin that can be registered in this hook.
The next function registered in this hook, either a custom function or Misago's default.
See the action section for details.
The request object.
The PrivateThreadReplyState object that stores all data to save to the database.
def save_private_thread_reply_state_action(
request: HttpRequest, state: 'PrivateThreadReplyState'
):
...A standard function that Misago uses to save a new private thread reply to the database.
The request object.
The PrivateThreadReplyState object that stores all data to save to the database.
The code below implements a custom filter function that stores the user's IP on the saved post.
from django.http import HttpRequest
from misago.posting.hooks import save_private_thread_reply_state_hook
from misago.posting.state import PrivateThreadReplyState
@save_private_thread_reply_state_hook.append_filter
def save_poster_ip_on_private_thread_reply(
action, request: HttpRequest, state: PrivateThreadReplyState
):
state.post.plugin_data["poster_ip"] = request.user_ip
action(request, state)