Skip to content

Commit c19fe5a

Browse files
fixes
1 parent a7cae35 commit c19fe5a

File tree

8 files changed

+61
-7
lines changed

8 files changed

+61
-7
lines changed

packages/models-library/src/models_library/api_schemas_webserver/groups.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ class MyGroupsGet(OutputSchema):
201201
description="Group ID of the app support team or None if no support is defined for this product"
202202
),
203203
] = None
204+
chatbot: Annotated[
205+
GroupGetBase | None,
206+
Field(
207+
description="Group ID of the support chatbot user or None if no chatbot is defined for this product"
208+
),
209+
] = None
204210

205211
model_config = ConfigDict(
206212
json_schema_extra={
@@ -245,6 +251,12 @@ class MyGroupsGet(OutputSchema):
245251
"description": "The support team of the application",
246252
"thumbnail": "https://placekitten.com/15/15",
247253
},
254+
"chatbot": {
255+
"gid": "6",
256+
"label": "Chatbot User",
257+
"description": "The chatbot user of the application",
258+
"thumbnail": "https://placekitten.com/15/15",
259+
},
248260
}
249261
}
250262
)
@@ -255,6 +267,7 @@ def from_domain_model(
255267
groups_by_type: GroupsByTypeTuple,
256268
my_product_group: tuple[Group, AccessRightsDict] | None,
257269
product_support_group: Group | None,
270+
product_chatbot_primary_group: Group | None,
258271
) -> Self:
259272
assert groups_by_type.primary # nosec
260273
assert groups_by_type.everyone # nosec
@@ -277,6 +290,13 @@ def from_domain_model(
277290
if product_support_group
278291
else None
279292
),
293+
chatbot=(
294+
GroupGetBase.model_validate(
295+
GroupGetBase.dump_basic_group_data(product_chatbot_primary_group)
296+
)
297+
if product_chatbot_primary_group
298+
else None
299+
),
280300
)
281301

282302

packages/models-library/src/models_library/api_schemas_webserver/users.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def from_domain_model(
172172
my_product_group: tuple[Group, AccessRightsDict] | None,
173173
my_preferences: AggregatedPreferences,
174174
my_support_group: Group | None,
175+
my_chatbot_user_group: Group | None,
175176
profile_contact: MyProfileAddressGet | None = None,
176177
) -> Self:
177178
profile_data = remap_keys(
@@ -194,7 +195,10 @@ def from_domain_model(
194195
return cls(
195196
**profile_data,
196197
groups=MyGroupsGet.from_domain_model(
197-
my_groups_by_type, my_product_group, my_support_group
198+
my_groups_by_type,
199+
my_product_group,
200+
my_support_group,
201+
my_chatbot_user_group,
198202
),
199203
preferences=my_preferences,
200204
contact=profile_contact,

packages/models-library/src/models_library/groups.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
7777
"type": "standard",
7878
"thumbnail": None,
7979
}
80+
chatbot: JsonDict = {
81+
"gid": 5,
82+
"name": "Chatbot",
83+
"description": "chatbot group",
84+
"type": "primary",
85+
"thumbnail": None,
86+
}
8087

8188
schema.update(
8289
{
@@ -86,6 +93,7 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
8693
organization,
8794
product,
8895
support,
96+
chatbot,
8997
]
9098
}
9199
)

packages/models-library/tests/test_users.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
from pydantic import TypeAdapter
99

1010

11+
@pytest.mark.parametrize("with_chatbot_user_group", [True, False])
1112
@pytest.mark.parametrize("with_support_group", [True, False])
1213
@pytest.mark.parametrize("with_standard_groups", [True, False])
1314
def test_adapter_from_model_to_schema(
14-
with_support_group: bool, with_standard_groups: bool
15+
with_support_group: bool, with_standard_groups: bool, with_chatbot_user_group: bool
1516
):
1617
my_profile = MyProfile.model_validate(MyProfile.model_json_schema()["example"])
1718

@@ -31,6 +32,7 @@ def test_adapter_from_model_to_schema(
3132
)
3233

3334
my_support_group = groups[4]
35+
my_chatbot_user_group = groups[5]
3436

3537
my_preferences = {"foo": Preference(default_value=3, value=1)}
3638

@@ -40,4 +42,5 @@ def test_adapter_from_model_to_schema(
4042
my_product_group,
4143
my_preferences,
4244
my_support_group if with_support_group else None,
45+
my_chatbot_user_group if with_chatbot_user_group else None,
4346
)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ async def create_support_message(
266266
return message
267267

268268
if is_first_message or conversation.fogbugz_case_id is None:
269-
_logger.debug(
269+
_logger.info(
270270
"Support settings available, this is first message, creating FogBugz case for Conversation ID: %s",
271271
conversation.conversation_id,
272272
)
@@ -298,7 +298,7 @@ async def create_support_message(
298298
)
299299
else:
300300
assert not is_first_message # nosec
301-
_logger.debug(
301+
_logger.info(
302302
"Support settings available, but this is NOT the first message, so we need to reopen a FogBugz case. Conversation ID: %s",
303303
conversation.conversation_id,
304304
)
@@ -329,7 +329,7 @@ async def create_support_message(
329329

330330
if (
331331
product.support_chatbot_user_id
332-
and conversation_user_type == ConversationUserType.CHATBOT_USER
332+
and conversation_user_type == ConversationUserType.REGULAR_USER
333333
):
334334
# If enabled, ask Chatbot to analyze the message history and respond
335335
await _trigger_chatbot_processing(

services/web/server/src/simcore_service_webserver/groups/_groups_rest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ async def list_groups(request: web.Request):
5151
groups_by_type,
5252
my_product_group,
5353
product_support_group,
54+
product_chatbot_primary_group,
5455
) = await _groups_service.get_user_profile_groups(
5556
request.app, user_id=req_ctx.user_id, product=product
5657
)
@@ -59,7 +60,10 @@ async def list_groups(request: web.Request):
5960
assert groups_by_type.everyone # nosec
6061

6162
my_groups = MyGroupsGet.from_domain_model(
62-
groups_by_type, my_product_group, product_support_group
63+
groups_by_type,
64+
my_product_group,
65+
product_support_group,
66+
product_chatbot_primary_group,
6367
)
6468

6569
return envelope_json_response(my_groups)

services/web/server/src/simcore_service_webserver/groups/_groups_service.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ async def get_user_profile_groups(
8484
GroupsByTypeTuple,
8585
tuple[Group, AccessRightsDict] | None,
8686
Group | None,
87+
Group | None,
8788
]:
8889
"""
8990
Get all groups needed for user profile including standard groups,
@@ -110,7 +111,19 @@ async def get_user_profile_groups(
110111
app, product.support_standard_group_id
111112
)
112113

113-
return groups_by_type, my_product_group, product_support_group
114+
product_chatbot_primary_group = None
115+
if product.support_chatbot_user_id:
116+
_group_id = users_service.get_user_primary_group_id(
117+
app, user_id=product.support_chatbot_user_id
118+
)
119+
product_chatbot_primary_group = await get_group_by_gid(app, _group_id)
120+
121+
return (
122+
groups_by_type,
123+
my_product_group,
124+
product_support_group,
125+
product_chatbot_primary_group,
126+
)
114127

115128

116129
#

services/web/server/src/simcore_service_webserver/users/_controller/rest/users_rest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ async def get_my_profile(request: web.Request) -> web.Response:
5656
groups_by_type,
5757
my_product_group,
5858
product_support_group,
59+
product_chatbot_primary_group,
5960
) = await groups_service.get_user_profile_groups(
6061
request.app, user_id=req_ctx.user_id, product=product
6162
)
@@ -85,6 +86,7 @@ async def get_my_profile(request: web.Request) -> web.Response:
8586
my_product_group,
8687
preferences,
8788
product_support_group,
89+
product_chatbot_primary_group,
8890
my_address,
8991
)
9092

0 commit comments

Comments
 (0)