Skip to content

Commit 1338bea

Browse files
committed
Add settingsSectionNotifications.
1 parent 3be25f6 commit 1338bea

3 files changed

Lines changed: 59 additions & 0 deletions

File tree

td/generate/scheme/td_api.tl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8313,6 +8313,22 @@ settingsSectionMyStars = SettingsSection;
83138313
//@description The Toncoin balance and transactions of the current user section
83148314
settingsSectionMyToncoins = SettingsSection;
83158315

8316+
//@description The notification settings section @subsection Subsection of the section if any; may be one of
8317+
//-"accounts", "private-chats", "private-chats/edit", "private-chats/show", "private-chats/preview",
8318+
//-"private-chats/sound", "private-chats/add-exception", "private-chats/delete-exceptions",
8319+
//-"private-chats/light-color", "private-chats/vibrate", "private-chats/priority", "groups", "groups/edit",
8320+
//-"groups/show", "groups/preview", "groups/sound", "groups/add-exception", "groups/delete-exceptions",
8321+
//-"groups/light-color", "groups/vibrate", "groups/priority", "channels", "channels/edit", "channels/show",
8322+
//-"channels/preview", "channels/sound", "channels/add-exception", "channels/delete-exceptions",
8323+
//-"channels/light-color", "channels/vibrate", "channels/priority", "stories", "stories/new", "stories/important",
8324+
//-"stories/show-sender", "stories/sound", "stories/add-exception", "stories/delete-exceptions",
8325+
//-"stories/light-color", "stories/vibrate", "stories/priority", "reactions", "reactions/messages",
8326+
//-"reactions/stories", "reactions/show-sender", "reactions/sound", "reactions/light-color", "reactions/vibrate",
8327+
//-"reactions/priority", "in-app-sounds", "in-app-vibrate", "in-app-preview", "in-chat-sounds", "in-app-popup",
8328+
//-"lock-screen-names", "include-channels", "include-muted-chats", "count-unread-messages", "new-contacts",
8329+
//-"pinned-messages", "reset", "web"
8330+
settingsSectionNotifications subsection:string = SettingsSection;
8331+
83168332
//@description The password set up section
83178333
settingsSectionPassword = SettingsSection;
83188334

td/telegram/LinkManager.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,26 @@ static const vector<string> &get_language_settings_subsections() {
209209
return subsections;
210210
}
211211

212+
static const vector<string> &get_notification_settings_subsections() {
213+
static const vector<string> subsections{
214+
"accounts", "private-chats", "private-chats/edit", "private-chats/show", "private-chats/preview",
215+
"private-chats/sound", "private-chats/add-exception", "private-chats/delete-exceptions",
216+
"private-chats/light-color", "private-chats/vibrate", "private-chats/priority", "groups", "groups/edit",
217+
"groups/show", "groups/preview", "groups/sound", "groups/add-exception", "groups/delete-exceptions",
218+
"groups/light-color", "groups/vibrate", "groups/priority", "channels", "channels/edit", "channels/show",
219+
"channels/preview", "channels/sound", "channels/add-exception", "channels/delete-exceptions",
220+
"channels/light-color", "channels/vibrate", "channels/priority", "stories", "stories/new", "stories/important",
221+
"stories/show-sender", "stories/sound", "stories/add-exception", "stories/delete-exceptions",
222+
"stories/light-color", "stories/vibrate", "stories/priority", "reactions", "reactions/messages",
223+
"reactions/stories", "reactions/show-sender", "reactions/sound", "reactions/light-color", "reactions/vibrate",
224+
"reactions/priority", "in-app-sounds", "in-app-vibrate", "in-app-preview", "in-chat-sounds", "in-app-popup",
225+
"lock-screen-names", "include-channels", "include-muted-chats", "count-unread-messages", "new-contacts",
226+
"pinned-messages", "reset",
227+
// no formatting
228+
"web"};
229+
return subsections;
230+
}
231+
212232
static const vector<string> &get_privacy_settings_subsections() {
213233
static const vector<string> subsections{
214234
"blocked", "blocked/edit", "blocked/block-user", "blocked/block-user/chats", "blocked/block-user/contacts",
@@ -972,6 +992,12 @@ class LinkManager::InternalLinkSettings final : public InternalLink {
972992
if (path_[0] == "login_email") {
973993
return td_api::make_object<td_api::settingsSectionLoginEmail>();
974994
}
995+
if (path_[0] == "notifications") {
996+
if (!subsection.empty() && td::contains(get_notification_settings_subsections(), subsection)) {
997+
return td_api::make_object<td_api::settingsSectionNotifications>(subsection);
998+
}
999+
return td_api::make_object<td_api::settingsSectionNotifications>();
1000+
}
9751001
if (path_[0] == "password") {
9761002
return td_api::make_object<td_api::settingsSectionPassword>();
9771003
}
@@ -3023,6 +3049,13 @@ Result<string> LinkManager::get_internal_link_impl(const td_api::InternalLinkTyp
30233049
return "tg://stars";
30243050
case td_api::settingsSectionMyToncoins::ID:
30253051
return "tg://ton";
3052+
case td_api::settingsSectionNotifications::ID: {
3053+
const auto &subsection = static_cast<const td_api::settingsSectionNotifications *>(section_ptr)->subsection_;
3054+
if (td::contains(get_notification_settings_subsections(), subsection)) {
3055+
return PSTRING() << "tg://settings/notifications/" << subsection;
3056+
}
3057+
return "tg://settings/notifications";
3058+
}
30263059
case td_api::settingsSectionPassword::ID:
30273060
return "tg://settings/password";
30283061
case td_api::settingsSectionPhoneNumber::ID:

test/link.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ static auto my_toncoins() {
345345
return settings(td::td_api::make_object<td::td_api::settingsSectionMyToncoins>());
346346
}
347347

348+
static auto notification_settings(td::string subsection = td::string()) {
349+
return settings(td::td_api::make_object<td::td_api::settingsSectionNotifications>(subsection));
350+
}
351+
348352
static auto passport_data_request(td::int32 bot_user_id, const td::string &scope, const td::string &public_key,
349353
const td::string &nonce, const td::string &callback_url) {
350354
return td::td_api::make_object<td::td_api::internalLinkTypePassportDataRequest>(bot_user_id, scope, public_key, nonce,
@@ -1701,6 +1705,7 @@ TEST(Link, parse_internal_link_part4) {
17011705
parse_internal_link("tg://settings/filters", settings());
17021706
parse_internal_link("tg://settings/language", language_settings());
17031707
parse_internal_link("tg://settings/login_email", login_email_settings());
1708+
parse_internal_link("tg://settings/notifications", notification_settings());
17041709
parse_internal_link("tg://settings/password", password_settings());
17051710
parse_internal_link("tg://settings/phone_privacy", privacy_and_security_settings("phone-number"));
17061711
parse_internal_link("tg://settings/privacy", privacy_and_security_settings());
@@ -1740,6 +1745,11 @@ TEST(Link, parse_internal_link_part4) {
17401745
parse_internal_link("tg://settings/profile-photo/use-emojis", edit_profile_settings("profile-photo"));
17411746
parse_internal_link("tg://settings/profile-photo/use-emoji", edit_profile_settings("profile-photo/use-emoji"));
17421747

1748+
parse_internal_link("tg://settings/notifications/app-icon", notification_settings());
1749+
parse_internal_link("tg://settings/notifications/reset", notification_settings("reset"));
1750+
parse_internal_link("tg://settings/notifications/groups/delete-exceptions",
1751+
notification_settings("groups/delete-exceptions"));
1752+
17431753
parse_internal_link("tg://stars", my_stars());
17441754
parse_internal_link("tg://stars?asdsa?D?SADasD?asD", my_stars());
17451755
parse_internal_link("tg://stars#test", my_stars());

0 commit comments

Comments
 (0)