def analize_object_for_watchers(obj:object, comment:str, user:object): """ Generic implementation for analize model objects and extract mentions from it and add it to watchers. """ if not hasattr(obj, "get_project"): return if not hasattr(obj, "add_watcher"): return from taiga import mdrender as mdr texts = (getattr(obj, "description", ""), getattr(obj, "content", ""), comment,) _, data = mdr.render_and_extract(obj.get_project(), "\n".join(texts)) if data["mentions"]: for user in data["mentions"]: obj.add_watcher(user) # Adding the person who edited the object to the watchers if comment and not user.is_system: obj.add_watcher(user)
def analize_object_for_watchers(obj: object, comment: str, user: object): """ Generic implementation for analize model objects and extract mentions from it and add it to watchers. """ if not hasattr(obj, "get_project"): return if not hasattr(obj, "add_watcher"): return from taiga import mdrender as mdr texts = ( getattr(obj, "description", ""), getattr(obj, "content", ""), comment, ) _, data = mdr.render_and_extract(obj.get_project(), "\n".join(texts)) if data["mentions"]: for user in data["mentions"]: obj.add_watcher(user) # Adding the person who edited the object to the watchers if comment and not user.is_system: obj.add_watcher(user)
def analize_object_for_watchers(obj:object, history:object): """ Generic implementation for analize model objects and extract mentions from it and add it to watchers. """ from taiga import mdrender as mdr texts = (getattr(obj, "description", ""), getattr(obj, "content", ""), getattr(history, "comment", ""),) _, data = mdr.render_and_extract(obj.get_project(), "\n".join(texts)) if data["mentions"]: for user in data["mentions"]: obj.watchers.add(user)