Skip to content

Commit 8c3c0a4

Browse files
fix: use user as recipients
1 parent 43d5749 commit 8c3c0a4

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

services/web/server/src/simcore_service_webserver/conversations/_conversation_message_service.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from models_library.users import UserID
1818

1919
from ..projects._groups_repository import list_project_groups
20+
from ..users._users_service import get_users_in_group
2021

2122
# Import or define SocketMessageDict
2223
from ..users.api import get_user_primary_group_id
@@ -30,13 +31,20 @@
3031
_logger = logging.getLogger(__name__)
3132

3233

33-
async def _get_recipients(app, project_id):
34-
return [
34+
async def _get_recipients(app, project_id) -> set[UserID]:
35+
groups = [
3536
project_to_group.gid
3637
for project_to_group in await list_project_groups(app, project_id=project_id)
3738
if project_to_group.read
3839
]
3940

41+
recipients = set()
42+
for group_id in groups:
43+
group_users = await get_users_in_group(app, gid=group_id)
44+
recipients.update(group_users)
45+
46+
return recipients
47+
4048

4149
async def create_message(
4250
app: web.Application,

services/web/server/src/simcore_service_webserver/conversations/_socketio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
ConversationMessageGetDB,
99
ConversationMessageID,
1010
)
11-
from models_library.groups import GroupID
1211
from models_library.projects import ProjectID
1312
from models_library.socketio import SocketMessageDict
13+
from models_library.users import UserID
1414
from pydantic import BaseModel
1515

1616
from ..socketio.messages import send_message_to_standard_group
@@ -52,7 +52,7 @@ async def _send_message_to_recipients(app, recipients, notification_message):
5252
async def notify_conversation_message_created(
5353
app: web.Application,
5454
*,
55-
recipients: list[GroupID],
55+
recipients: list[UserID],
5656
project_id: ProjectID,
5757
conversation_message: ConversationMessageGetDB,
5858
) -> None:
@@ -72,7 +72,7 @@ async def notify_conversation_message_created(
7272
async def notify_conversation_message_updated(
7373
app: web.Application,
7474
*,
75-
recipients: list[GroupID],
75+
recipients: list[UserID],
7676
project_id: ProjectID,
7777
conversation_message: ConversationMessageGetDB,
7878
) -> None:
@@ -93,7 +93,7 @@ async def notify_conversation_message_updated(
9393
async def notify_conversation_message_deleted(
9494
app: web.Application,
9595
*,
96-
recipients: list[GroupID],
96+
recipients: list[UserID],
9797
project_id: ProjectID,
9898
conversation_id: ConversationID,
9999
message_id: ConversationMessageID,

0 commit comments

Comments
 (0)