|
6 | 6 | from typing import List
|
7 | 7 | from flask import current_app
|
8 | 8 | from sqlalchemy import text, func
|
| 9 | +from markdown import markdown |
9 | 10 |
|
10 | 11 | from backend import create_app, db
|
11 | 12 | from backend.models.dtos.message_dto import MessageDTO, MessagesDTO
|
@@ -114,12 +115,10 @@ def send_message_to_all_contributors(project_id: int, message_dto: MessageDTO):
|
114 | 115 |
|
115 | 116 | with app.app_context():
|
116 | 117 | contributors = Message.get_all_contributors(project_id)
|
117 |
| - |
118 |
| - project_link = MessageService.get_project_link(project_id) |
119 |
| - |
120 |
| - message_dto.message = ( |
121 |
| - f"{project_link}<br/><br/>" + message_dto.message |
122 |
| - ) # Append project link to end of message |
| 118 | + message_dto.message = "A message from {} managers:<br/><br/>{}".format( |
| 119 | + MessageService.get_project_link(project_id), |
| 120 | + markdown(message_dto.message, output_format="html"), |
| 121 | + ) |
123 | 122 |
|
124 | 123 | messages = []
|
125 | 124 | for contributor in contributors:
|
@@ -157,6 +156,12 @@ def _push_messages(messages):
|
157 | 156 | and obj.message_type == MessageType.BROADCAST.value
|
158 | 157 | ):
|
159 | 158 | continue
|
| 159 | + if ( |
| 160 | + user.teams_notifications is False |
| 161 | + and obj.message_type == MessageType.TEAM_BROADCAST.value |
| 162 | + ): |
| 163 | + messages_objs.append(obj) |
| 164 | + continue |
160 | 165 | if user.comments_notifications is False and obj.message_type in (
|
161 | 166 | MessageType.TASK_COMMENT_NOTIFICATION.value,
|
162 | 167 | MessageType.PROJECT_CHAT_NOTIFICATION.value,
|
@@ -365,7 +370,7 @@ def send_message_after_chat(chat_from: int, chat: str, project_id: int):
|
365 | 370 | if len(usernames) == 0:
|
366 | 371 | return # Nobody @'d so return
|
367 | 372 |
|
368 |
| - link = MessageService.get_project_link(project_id) |
| 373 | + link = MessageService.get_project_link(project_id, include_chat_section=True) |
369 | 374 |
|
370 | 375 | messages = []
|
371 | 376 | for username in usernames:
|
@@ -394,7 +399,9 @@ def send_message_after_chat(chat_from: int, chat: str, project_id: int):
|
394 | 399 | favorited_users = [r[0] for r in result]
|
395 | 400 |
|
396 | 401 | if len(favorited_users) != 0:
|
397 |
| - project_link = MessageService.get_project_link(project_id) |
| 402 | + project_link = MessageService.get_project_link( |
| 403 | + project_id, include_chat_section=True |
| 404 | + ) |
398 | 405 | # project_title = ProjectService.get_project_title(project_id)
|
399 | 406 | messages = []
|
400 | 407 | for user_id in favorited_users:
|
@@ -642,12 +649,18 @@ def get_task_link(project_id: int, task_id: int, base_url=None) -> str:
|
642 | 649 | return f'<a href="{base_url}/projects/{project_id}/tasks/?search={task_id}">Task {task_id}</a>'
|
643 | 650 |
|
644 | 651 | @staticmethod
|
645 |
| - def get_project_link(project_id: int, base_url=None) -> str: |
| 652 | + def get_project_link( |
| 653 | + project_id: int, base_url=None, include_chat_section=False |
| 654 | + ) -> str: |
646 | 655 | """ Helper method to generate a link to project chat"""
|
647 | 656 | if not base_url:
|
648 | 657 | base_url = current_app.config["APP_BASE_URL"]
|
| 658 | + if include_chat_section: |
| 659 | + section = "#questionsAndComments" |
| 660 | + else: |
| 661 | + section = "" |
649 | 662 |
|
650 |
| - return f'<a href="{base_url}/projects/{project_id}#questionsAndComments">Project {project_id}</a>' |
| 663 | + return f'<a href="{base_url}/projects/{project_id}{section}">Project {project_id}</a>' |
651 | 664 |
|
652 | 665 | @staticmethod
|
653 | 666 | def get_user_profile_link(user_name: str, base_url=None) -> str:
|
|
0 commit comments