This hook wraps the standard function that Misago uses to set related objects on dicts containing posts feed data.
This hook can be imported from misago.threads.hooks:
from misago.threads.hooks import set_post_feed_related_objects_hookdef custom_set_post_feed_related_objects_filter(
action: SetPostFeedRelatedObjectsHookAction,
feed: list[dict],
related_objects: dict,
):
...A function implemented by a plugin that can be registered in this hook.
Next function registered in this hook, either a custom function or Misago's standard one.
See the action section for details.
A list of dict objects with post feed items. This function updates these dicts with objects from the related_objects dictionary.
A dict with objects related to the feed's items.
def set_post_feed_related_objects_action(feed: list[dict], related_objects: dict):
...Misago function used to set related objects on dicts containing posts feed data.
A list of dict objects with post feed items. This function updates these dicts with objects from the related_objects dictionary.
A dict with objects related to the feed's items.
The code below implements a custom filter function that populates feed's items with plugin objects
from misago.threads.hooks import set_post_feed_related_objects_hook
@set_post_feed_related_objects_hook.append_filter
def replace_post_poster(
action, feed: list[dict], related_objects: dict
):
action(feed, related_objects)
for item in feed:
if item["type"] == "post":
plugin_obj = related_objects["plugin_objects"].get(
item["post"].plugin_data["plugin_relation_id"]
)
item["plugin_attr"] = plugin_obj