Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pybotx/bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,9 @@ async def send_smartapp_manifest(
android: Missing[SmartappManifestAndroidParams] = Undefined,
web_layout: Missing[SmartappManifestWebParams] = Undefined,
unread_counter: Missing[SmartappManifestUnreadCounterParams] = Undefined,
store_on_close: Missing[bool] = Undefined,
preload_in_background: Missing[bool] = Undefined,
link_regex: Missing[str | None] = Undefined,
) -> SmartappManifest:
"""Send smartapp manifest with given parameters.

Expand All @@ -1791,6 +1794,9 @@ async def send_smartapp_manifest(
:param android: Smartapp layout for android clients.
:param web_layout: Smartapp layout for web clients.
:param unread_counter: Entities that can be subscribed to in the unread counter.
:param store_on_close: Keep smartapp in memory on close.
:param preload_in_background: Force load smartapp even not pinned.
:param link_regex: URLs matching this Regex will be opened by the current SmartApp.

:return: Smartapp manifest with the set parameters received from BotX.
"""
Expand All @@ -1805,6 +1811,9 @@ async def send_smartapp_manifest(
android=android,
web_layout=web_layout,
unread_counter=unread_counter,
store_on_close=store_on_close,
preload_in_background=preload_in_background,
link_regex=link_regex,
)
smartapp_manifest_response = await method.execute(payload)
return smartapp_manifest_response.to_domain()
Expand Down
12 changes: 12 additions & 0 deletions pybotx/client/smartapps_api/smartapp_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class SmartappManifest(VerifiedPayloadBaseModel):
android: SmartappManifestAndroidParams
web: SmartappManifestWebParams
unread_counter_link: SmartappManifestUnreadCounterParams
store_on_close: bool = False
preload_in_background: bool = False
link_regex: str | None = None


class SmartappManifestPayload(UnverifiedPayloadBaseModel):
Expand All @@ -46,6 +49,9 @@ class SmartappManifestPayload(UnverifiedPayloadBaseModel):
web: Missing[SmartappManifestWebParams] = Undefined
aurora: Missing[SmartappManifestAuroraParams] = Undefined
unread_counter_link: Missing[SmartappManifestUnreadCounterParams] = Undefined
store_on_close: Missing[bool] = Undefined
preload_in_background: Missing[bool] = Undefined
link_regex: Missing[str | None] = Undefined


class BotXAPISmartAppManifestRequestPayload(UnverifiedPayloadBaseModel):
Expand All @@ -58,6 +64,9 @@ def from_domain(
android: Missing[SmartappManifestAndroidParams] = Undefined,
web_layout: Missing[SmartappManifestWebParams] = Undefined,
unread_counter: Missing[SmartappManifestUnreadCounterParams] = Undefined,
store_on_close: Missing[bool] = Undefined,
preload_in_background: Missing[bool] = Undefined,
link_regex: Missing[str | None] = Undefined,
) -> "BotXAPISmartAppManifestRequestPayload":
if web_layout is Undefined and unread_counter is Undefined:
return cls(manifest={})
Expand All @@ -68,6 +77,9 @@ def from_domain(
android=android,
web=web_layout,
unread_counter_link=unread_counter,
store_on_close=store_on_close,
preload_in_background=preload_in_background,
link_regex=link_regex,
),
)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pybotx"
version = "0.76.0"
version = "0.76.1"
description = "A python library for interacting with eXpress BotX API"
authors = [
"Sidnev Nikolay <nsidnev@ccsteam.ru>",
Expand Down
19 changes: 19 additions & 0 deletions tests/client/smartapps_api/test_smartapp_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ async def test__send_smartapp_manifest__all_params_provided__succeed(
"group_chat_id": ["adc03af8-9193-4d3b-b913-7a023cdb4029"],
"app_id": ["test_app"],
},
"store_on_close": True,
"preload_in_background": False,
"link_regex": "^https:\\/\\/site\\.com.*$",
},
},
).mock(
Expand All @@ -80,6 +83,9 @@ async def test__send_smartapp_manifest__all_params_provided__succeed(
"group_chat_id": ["adc03af8-9193-4d3b-b913-7a023cdb4029"],
"app_id": ["test_app"],
},
"store_on_close": True,
"preload_in_background": False,
"link_regex": "^https:\\/\\/site\\.com.*$",
},
"status": "ok",
},
Expand Down Expand Up @@ -108,6 +114,9 @@ async def test__send_smartapp_manifest__all_params_provided__succeed(
group_chat_id=[UUID("adc03af8-9193-4d3b-b913-7a023cdb4029")],
app_id=["test_app"],
),
store_on_close=True,
preload_in_background=False,
link_regex="^https:\\/\\/site\\.com.*$",
)

# - Assert -
Expand All @@ -129,6 +138,9 @@ async def test__send_smartapp_manifest__all_params_provided__succeed(
group_chat_id=[UUID("adc03af8-9193-4d3b-b913-7a023cdb4029")],
app_id=["test_app"],
),
store_on_close=True,
preload_in_background=False,
link_regex="^https:\\/\\/site\\.com.*$",
)


Expand Down Expand Up @@ -167,6 +179,10 @@ async def test__send_smartapp_manifest__only_default_params_provided__succeed(
"group_chat_id": [],
"user_huid": [],
},
"store_on_close": False,
"preload_in_background": False,
"link_regex": None,

},
"status": "ok",
},
Expand Down Expand Up @@ -198,6 +214,9 @@ async def test__send_smartapp_manifest__only_default_params_provided__succeed(
group_chat_id=[],
app_id=[],
),
store_on_close=False,
preload_in_background=False,
link_regex=None,
)


Expand Down
Loading