Skip to content

Commit b3bc1eb

Browse files
authored
feat: new smartapp manifest fields
1 parent 726b02a commit b3bc1eb

4 files changed

Lines changed: 41 additions & 1 deletion

File tree

pybotx/bot/bot.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,9 @@ async def send_smartapp_manifest(
17831783
android: Missing[SmartappManifestAndroidParams] = Undefined,
17841784
web_layout: Missing[SmartappManifestWebParams] = Undefined,
17851785
unread_counter: Missing[SmartappManifestUnreadCounterParams] = Undefined,
1786+
store_on_close: Missing[bool] = Undefined,
1787+
preload_in_background: Missing[bool] = Undefined,
1788+
link_regex: Missing[str | None] = Undefined,
17861789
) -> SmartappManifest:
17871790
"""Send smartapp manifest with given parameters.
17881791
@@ -1791,6 +1794,9 @@ async def send_smartapp_manifest(
17911794
:param android: Smartapp layout for android clients.
17921795
:param web_layout: Smartapp layout for web clients.
17931796
:param unread_counter: Entities that can be subscribed to in the unread counter.
1797+
:param store_on_close: Keep smartapp in memory on close.
1798+
:param preload_in_background: Force load smartapp even not pinned.
1799+
:param link_regex: URLs matching this Regex will be opened by the current SmartApp.
17941800
17951801
:return: Smartapp manifest with the set parameters received from BotX.
17961802
"""
@@ -1805,6 +1811,9 @@ async def send_smartapp_manifest(
18051811
android=android,
18061812
web_layout=web_layout,
18071813
unread_counter=unread_counter,
1814+
store_on_close=store_on_close,
1815+
preload_in_background=preload_in_background,
1816+
link_regex=link_regex,
18081817
)
18091818
smartapp_manifest_response = await method.execute(payload)
18101819
return smartapp_manifest_response.to_domain()

pybotx/client/smartapps_api/smartapp_manifest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class SmartappManifest(VerifiedPayloadBaseModel):
3838
android: SmartappManifestAndroidParams
3939
web: SmartappManifestWebParams
4040
unread_counter_link: SmartappManifestUnreadCounterParams
41+
store_on_close: bool = False
42+
preload_in_background: bool = False
43+
link_regex: str | None = None
4144

4245

4346
class SmartappManifestPayload(UnverifiedPayloadBaseModel):
@@ -46,6 +49,9 @@ class SmartappManifestPayload(UnverifiedPayloadBaseModel):
4649
web: Missing[SmartappManifestWebParams] = Undefined
4750
aurora: Missing[SmartappManifestAuroraParams] = Undefined
4851
unread_counter_link: Missing[SmartappManifestUnreadCounterParams] = Undefined
52+
store_on_close: Missing[bool] = Undefined
53+
preload_in_background: Missing[bool] = Undefined
54+
link_regex: Missing[str | None] = Undefined
4955

5056

5157
class BotXAPISmartAppManifestRequestPayload(UnverifiedPayloadBaseModel):
@@ -58,6 +64,9 @@ def from_domain(
5864
android: Missing[SmartappManifestAndroidParams] = Undefined,
5965
web_layout: Missing[SmartappManifestWebParams] = Undefined,
6066
unread_counter: Missing[SmartappManifestUnreadCounterParams] = Undefined,
67+
store_on_close: Missing[bool] = Undefined,
68+
preload_in_background: Missing[bool] = Undefined,
69+
link_regex: Missing[str | None] = Undefined,
6170
) -> "BotXAPISmartAppManifestRequestPayload":
6271
if web_layout is Undefined and unread_counter is Undefined:
6372
return cls(manifest={})
@@ -68,6 +77,9 @@ def from_domain(
6877
android=android,
6978
web=web_layout,
7079
unread_counter_link=unread_counter,
80+
store_on_close=store_on_close,
81+
preload_in_background=preload_in_background,
82+
link_regex=link_regex,
7183
),
7284
)
7385

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pybotx"
3-
version = "0.76.0"
3+
version = "0.76.1"
44
description = "A python library for interacting with eXpress BotX API"
55
authors = [
66
"Sidnev Nikolay <nsidnev@ccsteam.ru>",

tests/client/smartapps_api/test_smartapp_manifest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ async def test__send_smartapp_manifest__all_params_provided__succeed(
5656
"group_chat_id": ["adc03af8-9193-4d3b-b913-7a023cdb4029"],
5757
"app_id": ["test_app"],
5858
},
59+
"store_on_close": True,
60+
"preload_in_background": False,
61+
"link_regex": "^https:\\/\\/site\\.com.*$",
5962
},
6063
},
6164
).mock(
@@ -80,6 +83,9 @@ async def test__send_smartapp_manifest__all_params_provided__succeed(
8083
"group_chat_id": ["adc03af8-9193-4d3b-b913-7a023cdb4029"],
8184
"app_id": ["test_app"],
8285
},
86+
"store_on_close": True,
87+
"preload_in_background": False,
88+
"link_regex": "^https:\\/\\/site\\.com.*$",
8389
},
8490
"status": "ok",
8591
},
@@ -108,6 +114,9 @@ async def test__send_smartapp_manifest__all_params_provided__succeed(
108114
group_chat_id=[UUID("adc03af8-9193-4d3b-b913-7a023cdb4029")],
109115
app_id=["test_app"],
110116
),
117+
store_on_close=True,
118+
preload_in_background=False,
119+
link_regex="^https:\\/\\/site\\.com.*$",
111120
)
112121

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

134146

@@ -167,6 +179,10 @@ async def test__send_smartapp_manifest__only_default_params_provided__succeed(
167179
"group_chat_id": [],
168180
"user_huid": [],
169181
},
182+
"store_on_close": False,
183+
"preload_in_background": False,
184+
"link_regex": None,
185+
170186
},
171187
"status": "ok",
172188
},
@@ -198,6 +214,9 @@ async def test__send_smartapp_manifest__only_default_params_provided__succeed(
198214
group_chat_id=[],
199215
app_id=[],
200216
),
217+
store_on_close=False,
218+
preload_in_background=False,
219+
link_regex=None,
201220
)
202221

203222

0 commit comments

Comments
 (0)