def create_assignation_notification(task_id, person_id, author_id=None): """ Create a notification following a task assignation. """ task = tasks_service.get_task_raw(task_id) if author_id is None: author_id = task.assigner_id if str(author_id) != person_id: notification = create_notification(person_id, author_id=author_id, task_id=task_id, type="assignation") emails_service.send_assignation_notification(person_id, author_id, task.serialize()) events.emit( "notification:new", { "notification_id": notification["id"], "person_id": person_id }, project_id=str(task.project_id), persist=False, ) return notification else: return None
def get_comment_mentions(object_id, text): """ Check for people mention (@full name) in text and returns matching person active records. """ task = tasks_service.get_task_raw(object_id) project = Project.get(task.project_id) mentions = [] for person in project.team: if re.search("@%s( |$)" % person.full_name(), text) is not None: mentions.append(person) return mentions
def create_assignation_notification(task_id, person_id, author_id=None): """ Create a notification following a task assignation. """ task = tasks_service.get_task_raw(task_id) if author_id is None: author_id = task.assigner_id notification = create_notification( person_id, author_id=author_id, task_id=task_id, type="assignation" ) events.emit("notification:new", { "notification_id": notification["id"], "person_id": person_id }, persist=False)