mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow all messages silent in support mode.
This commit is contained in:
parent
1affb8172f
commit
00504b61cd
8 changed files with 70 additions and 38 deletions
|
@ -86,8 +86,7 @@ void SendExistingMedia(
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to_msg_id;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_reply_to_msg_id;
|
||||||
}
|
}
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
const auto anonymousPost = peer->amAnonymous();
|
||||||
const auto silentPost = message.action.options.silent
|
const auto silentPost = ShouldSendSilent(peer, message.action.options);
|
||||||
|| (peer->isBroadcast() && session->data().notifySilentPosts(peer));
|
|
||||||
InnerFillMessagePostFlags(message.action.options, peer, flags);
|
InnerFillMessagePostFlags(message.action.options, peer, flags);
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
||||||
|
@ -261,8 +260,7 @@ bool SendDice(Api::MessageToSend &message) {
|
||||||
}
|
}
|
||||||
const auto replyHeader = NewMessageReplyHeader(message.action);
|
const auto replyHeader = NewMessageReplyHeader(message.action);
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
const auto anonymousPost = peer->amAnonymous();
|
||||||
const auto silentPost = message.action.options.silent
|
const auto silentPost = ShouldSendSilent(peer, message.action.options);
|
||||||
|| (peer->isBroadcast() && session->data().notifySilentPosts(peer));
|
|
||||||
InnerFillMessagePostFlags(message.action.options, peer, flags);
|
InnerFillMessagePostFlags(message.action.options, peer, flags);
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
||||||
|
@ -403,7 +401,7 @@ void SendConfirmedFile(
|
||||||
}
|
}
|
||||||
const auto replyHeader = NewMessageReplyHeader(action);
|
const auto replyHeader = NewMessageReplyHeader(action);
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
const auto anonymousPost = peer->amAnonymous();
|
||||||
const auto silentPost = file->to.options.silent;
|
const auto silentPost = ShouldSendSilent(peer, file->to.options);
|
||||||
Api::FillMessagePostFlags(action, peer, flags);
|
Api::FillMessagePostFlags(action, peer, flags);
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
flags |= MTPDmessage::Flag::f_silent;
|
flags |= MTPDmessage::Flag::f_silent;
|
||||||
|
|
|
@ -3955,8 +3955,7 @@ void ApiWrap::forwardMessages(
|
||||||
histories.readInbox(history);
|
histories.readInbox(history);
|
||||||
|
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
const auto anonymousPost = peer->amAnonymous();
|
||||||
const auto silentPost = action.options.silent
|
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||||
|| (peer->isBroadcast() && _session->data().notifySilentPosts(peer));
|
|
||||||
|
|
||||||
auto flags = MTPDmessage::Flags(0);
|
auto flags = MTPDmessage::Flags(0);
|
||||||
auto clientFlags = MTPDmessage_ClientFlags();
|
auto clientFlags = MTPDmessage_ClientFlags();
|
||||||
|
@ -4155,11 +4154,7 @@ void ApiWrap::sendSharedContact(
|
||||||
MTP_string(firstName),
|
MTP_string(firstName),
|
||||||
MTP_string(lastName),
|
MTP_string(lastName),
|
||||||
MTP_string(vcard));
|
MTP_string(vcard));
|
||||||
auto options = action.options;
|
sendMedia(item, media, action.options);
|
||||||
if (_session->data().notifySilentPosts(peer)) {
|
|
||||||
options.silent = true;
|
|
||||||
}
|
|
||||||
sendMedia(item, media, options);
|
|
||||||
|
|
||||||
_session->data().sendHistoryChangeNotifications();
|
_session->data().sendHistoryChangeNotifications();
|
||||||
_session->changes().historyUpdated(
|
_session->changes().historyUpdated(
|
||||||
|
@ -4374,8 +4369,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||||
flags |= MTPDmessage::Flag::f_media;
|
flags |= MTPDmessage::Flag::f_media;
|
||||||
}
|
}
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
const auto anonymousPost = peer->amAnonymous();
|
||||||
const auto silentPost = action.options.silent
|
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||||
|| (peer->isBroadcast() && _session->data().notifySilentPosts(peer));
|
|
||||||
FillMessagePostFlags(action, peer, flags);
|
FillMessagePostFlags(action, peer, flags);
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
sendFlags |= MTPmessages_SendMessage::Flag::f_silent;
|
sendFlags |= MTPmessages_SendMessage::Flag::f_silent;
|
||||||
|
@ -4516,8 +4510,7 @@ void ApiWrap::sendInlineResult(
|
||||||
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_reply_to_msg_id;
|
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_reply_to_msg_id;
|
||||||
}
|
}
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
const auto anonymousPost = peer->amAnonymous();
|
||||||
const auto silentPost = action.options.silent
|
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||||
|| (peer->isBroadcast() && _session->data().notifySilentPosts(peer));
|
|
||||||
FillMessagePostFlags(action, peer, flags);
|
FillMessagePostFlags(action, peer, flags);
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_silent;
|
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_silent;
|
||||||
|
@ -4683,7 +4676,7 @@ void ApiWrap::sendMediaWithRandomId(
|
||||||
| (replyTo
|
| (replyTo
|
||||||
? MTPmessages_SendMedia::Flag::f_reply_to_msg_id
|
? MTPmessages_SendMedia::Flag::f_reply_to_msg_id
|
||||||
: MTPmessages_SendMedia::Flag(0))
|
: MTPmessages_SendMedia::Flag(0))
|
||||||
| (options.silent
|
| (ShouldSendSilent(history->peer, options)
|
||||||
? MTPmessages_SendMedia::Flag::f_silent
|
? MTPmessages_SendMedia::Flag::f_silent
|
||||||
: MTPmessages_SendMedia::Flag(0))
|
: MTPmessages_SendMedia::Flag(0))
|
||||||
| (!sentEntities.v.isEmpty()
|
| (!sentEntities.v.isEmpty()
|
||||||
|
@ -4790,7 +4783,7 @@ void ApiWrap::sendAlbumIfReady(not_null<SendingAlbum*> album) {
|
||||||
| (replyTo
|
| (replyTo
|
||||||
? MTPmessages_SendMultiMedia::Flag::f_reply_to_msg_id
|
? MTPmessages_SendMultiMedia::Flag::f_reply_to_msg_id
|
||||||
: MTPmessages_SendMultiMedia::Flag(0))
|
: MTPmessages_SendMultiMedia::Flag(0))
|
||||||
| (album->options.silent
|
| (ShouldSendSilent(history->peer, album->options)
|
||||||
? MTPmessages_SendMultiMedia::Flag::f_silent
|
? MTPmessages_SendMultiMedia::Flag::f_silent
|
||||||
: MTPmessages_SendMultiMedia::Flag(0))
|
: MTPmessages_SendMultiMedia::Flag(0))
|
||||||
| (album->options.scheduled
|
| (album->options.scheduled
|
||||||
|
@ -4828,10 +4821,6 @@ void ApiWrap::sendAlbumIfReady(not_null<SendingAlbum*> album) {
|
||||||
|
|
||||||
FileLoadTo ApiWrap::fileLoadTaskOptions(const SendAction &action) const {
|
FileLoadTo ApiWrap::fileLoadTaskOptions(const SendAction &action) const {
|
||||||
const auto peer = action.history->peer;
|
const auto peer = action.history->peer;
|
||||||
auto options = action.options;
|
|
||||||
if (_session->data().notifySilentPosts(peer)) {
|
|
||||||
options.silent = true;
|
|
||||||
}
|
|
||||||
return FileLoadTo(peer->id, action.options, action.replyTo);
|
return FileLoadTo(peer->id, action.options, action.replyTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5261,8 +5250,7 @@ void ApiWrap::createPoll(
|
||||||
history->clearLocalDraft();
|
history->clearLocalDraft();
|
||||||
history->clearCloudDraft();
|
history->clearCloudDraft();
|
||||||
}
|
}
|
||||||
const auto silentPost = action.options.silent
|
const auto silentPost = ShouldSendSilent(peer, action.options);
|
||||||
|| (peer->isBroadcast() && _session->data().notifySilentPosts(peer));
|
|
||||||
if (silentPost) {
|
if (silentPost) {
|
||||||
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
sendFlags |= MTPmessages_SendMedia::Flag::f_silent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/view/media/history_view_media.h" // AddTimestampLinks.
|
#include "history/view/media/history_view_media.h" // AddTimestampLinks.
|
||||||
#include "chat_helpers/stickers_emoji_pack.h"
|
#include "chat_helpers/stickers_emoji_pack.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "main/main_session_settings.h"
|
||||||
#include "api/api_updates.h"
|
#include "api/api_updates.h"
|
||||||
#include "boxes/share_box.h"
|
#include "boxes/share_box.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
|
@ -277,11 +278,8 @@ void FastShareMessage(not_null<HistoryItem*> item) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto sendFlags = MTPmessages_ForwardMessages::Flag(0)
|
const auto commonSendFlags = MTPmessages_ForwardMessages::Flag(0)
|
||||||
| MTPmessages_ForwardMessages::Flag::f_with_my_score
|
| MTPmessages_ForwardMessages::Flag::f_with_my_score
|
||||||
| (options.silent
|
|
||||||
? MTPmessages_ForwardMessages::Flag::f_silent
|
|
||||||
: MTPmessages_ForwardMessages::Flag(0))
|
|
||||||
| (options.scheduled
|
| (options.scheduled
|
||||||
? MTPmessages_ForwardMessages::Flag::f_schedule_date
|
? MTPmessages_ForwardMessages::Flag::f_schedule_date
|
||||||
: MTPmessages_ForwardMessages::Flag(0));
|
: MTPmessages_ForwardMessages::Flag(0));
|
||||||
|
@ -311,13 +309,17 @@ void FastShareMessage(not_null<HistoryItem*> item) {
|
||||||
}
|
}
|
||||||
histories.sendRequest(history, requestType, [=](Fn<void()> finish) {
|
histories.sendRequest(history, requestType, [=](Fn<void()> finish) {
|
||||||
auto &api = history->session().api();
|
auto &api = history->session().api();
|
||||||
|
const auto sendFlags = commonSendFlags
|
||||||
|
| (ShouldSendSilent(peer, options)
|
||||||
|
? MTPmessages_ForwardMessages::Flag::f_silent
|
||||||
|
: MTPmessages_ForwardMessages::Flag(0));
|
||||||
history->sendRequestId = api.request(MTPmessages_ForwardMessages(
|
history->sendRequestId = api.request(MTPmessages_ForwardMessages(
|
||||||
MTP_flags(sendFlags),
|
MTP_flags(sendFlags),
|
||||||
data->peer->input,
|
data->peer->input,
|
||||||
MTP_vector<MTPint>(msgIds),
|
MTP_vector<MTPint>(msgIds),
|
||||||
MTP_vector<MTPlong>(generateRandom()),
|
MTP_vector<MTPlong>(generateRandom()),
|
||||||
peer->input,
|
peer->input,
|
||||||
MTP_int(options.scheduled)
|
MTP_int(options.scheduled)
|
||||||
)).done([=](const MTPUpdates &updates, mtpRequestId requestId) {
|
)).done([=](const MTPUpdates &updates, mtpRequestId requestId) {
|
||||||
history->session().api().applyUpdates(updates);
|
history->session().api().applyUpdates(updates);
|
||||||
data->requests.remove(requestId);
|
data->requests.remove(requestId);
|
||||||
|
@ -375,6 +377,15 @@ MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ShouldSendSilent(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const Api::SendOptions &options) {
|
||||||
|
return options.silent
|
||||||
|
|| (peer->isBroadcast() && peer->owner().notifySilentPosts(peer))
|
||||||
|
|| (peer->session().supportMode()
|
||||||
|
&& peer->session().settings().supportAllSilent());
|
||||||
|
}
|
||||||
|
|
||||||
MsgId LookupReplyToTop(not_null<History*> history, MsgId replyToId) {
|
MsgId LookupReplyToTop(not_null<History*> history, MsgId replyToId) {
|
||||||
const auto &owner = history->owner();
|
const auto &owner = history->owner();
|
||||||
if (const auto item = owner.message(history->channelId(), replyToId)) {
|
if (const auto item = owner.message(history->channelId(), replyToId)) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Api {
|
namespace Api {
|
||||||
struct SendAction;
|
struct SendAction;
|
||||||
|
struct SendOptions;
|
||||||
} // namespace Api
|
} // namespace Api
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
@ -24,6 +25,9 @@ struct HistoryMessageViews;
|
||||||
[[nodiscard]] Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
|
[[nodiscard]] Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
|
||||||
not_null<HistoryItem*> item);
|
not_null<HistoryItem*> item);
|
||||||
[[nodiscard]] MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer);
|
[[nodiscard]] MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer);
|
||||||
|
[[nodiscard]] bool ShouldSendSilent(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
const Api::SendOptions &options);
|
||||||
[[nodiscard]] MTPDmessage_ClientFlags NewMessageClientFlags();
|
[[nodiscard]] MTPDmessage_ClientFlags NewMessageClientFlags();
|
||||||
[[nodiscard]] MsgId LookupReplyToTop(
|
[[nodiscard]] MsgId LookupReplyToTop(
|
||||||
not_null<History*> history,
|
not_null<History*> history,
|
||||||
|
|
|
@ -69,6 +69,7 @@ QByteArray SessionSettings::serialize() const {
|
||||||
stream << quint64(key) << qint32(value);
|
stream << quint64(key) << qint32(value);
|
||||||
}
|
}
|
||||||
stream << qint32(_dialogsFiltersEnabled ? 1 : 0);
|
stream << qint32(_dialogsFiltersEnabled ? 1 : 0);
|
||||||
|
stream << qint32(_supportAllSilent ? 1 : 0);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -127,6 +128,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||||
qint32 appAutoDownloadDictionaries = app.autoDownloadDictionaries() ? 1 : 0;
|
qint32 appAutoDownloadDictionaries = app.autoDownloadDictionaries() ? 1 : 0;
|
||||||
base::flat_map<PeerId, MsgId> hiddenPinnedMessages;
|
base::flat_map<PeerId, MsgId> hiddenPinnedMessages;
|
||||||
qint32 dialogsFiltersEnabled = _dialogsFiltersEnabled ? 1 : 0;
|
qint32 dialogsFiltersEnabled = _dialogsFiltersEnabled ? 1 : 0;
|
||||||
|
qint32 supportAllSilent = _supportAllSilent ? 1 : 0;
|
||||||
|
|
||||||
stream >> versionTag;
|
stream >> versionTag;
|
||||||
if (versionTag == kVersionTag) {
|
if (versionTag == kVersionTag) {
|
||||||
|
@ -321,6 +323,9 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
stream >> dialogsFiltersEnabled;
|
stream >> dialogsFiltersEnabled;
|
||||||
}
|
}
|
||||||
|
if (!stream.atEnd()) {
|
||||||
|
stream >> supportAllSilent;
|
||||||
|
}
|
||||||
if (stream.status() != QDataStream::Ok) {
|
if (stream.status() != QDataStream::Ok) {
|
||||||
LOG(("App Error: "
|
LOG(("App Error: "
|
||||||
"Bad data for SessionSettings::addFromSerialized()"));
|
"Bad data for SessionSettings::addFromSerialized()"));
|
||||||
|
@ -362,6 +367,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
|
||||||
_mediaLastPlaybackPosition = std::move(mediaLastPlaybackPosition);
|
_mediaLastPlaybackPosition = std::move(mediaLastPlaybackPosition);
|
||||||
_hiddenPinnedMessages = std::move(hiddenPinnedMessages);
|
_hiddenPinnedMessages = std::move(hiddenPinnedMessages);
|
||||||
_dialogsFiltersEnabled = (dialogsFiltersEnabled == 1);
|
_dialogsFiltersEnabled = (dialogsFiltersEnabled == 1);
|
||||||
|
_supportAllSilent = (supportAllSilent == 1);
|
||||||
|
|
||||||
if (version < 2) {
|
if (version < 2) {
|
||||||
app.setLastSeenWarningSeen(appLastSeenWarningSeen == 1);
|
app.setLastSeenWarningSeen(appLastSeenWarningSeen == 1);
|
||||||
|
|
|
@ -51,6 +51,12 @@ public:
|
||||||
void setSupportAllSearchResults(bool all);
|
void setSupportAllSearchResults(bool all);
|
||||||
[[nodiscard]] bool supportAllSearchResults() const;
|
[[nodiscard]] bool supportAllSearchResults() const;
|
||||||
[[nodiscard]] rpl::producer<bool> supportAllSearchResultsValue() const;
|
[[nodiscard]] rpl::producer<bool> supportAllSearchResultsValue() const;
|
||||||
|
void setSupportAllSilent(bool enabled) {
|
||||||
|
_supportAllSilent = enabled;
|
||||||
|
}
|
||||||
|
[[nodiscard]] bool supportAllSilent() const {
|
||||||
|
return _supportAllSilent;
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] ChatHelpers::SelectorTab selectorTab() const {
|
[[nodiscard]] ChatHelpers::SelectorTab selectorTab() const {
|
||||||
return _selectorTab;
|
return _selectorTab;
|
||||||
|
@ -131,6 +137,7 @@ private:
|
||||||
Support::SwitchSettings _supportSwitch;
|
Support::SwitchSettings _supportSwitch;
|
||||||
bool _supportFixChatsOrder = true;
|
bool _supportFixChatsOrder = true;
|
||||||
bool _supportTemplatesAutocomplete = true;
|
bool _supportTemplatesAutocomplete = true;
|
||||||
|
bool _supportAllSilent = false;
|
||||||
rpl::variable<int> _supportChatsTimeSlice
|
rpl::variable<int> _supportChatsTimeSlice
|
||||||
= kDefaultSupportChatsLimitSlice;
|
= kDefaultSupportChatsLimitSlice;
|
||||||
rpl::variable<bool> _supportAllSearchResults = false;
|
rpl::variable<bool> _supportAllSearchResults = false;
|
||||||
|
|
|
@ -158,11 +158,15 @@ ApplicationDelegate *_sharedDelegate = nil;
|
||||||
if (!Core::IsAppLaunched()) {
|
if (!Core::IsAppLaunched()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Core::App().checkLocalTime();
|
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||||
|
Core::App().checkLocalTime();
|
||||||
|
|
||||||
LOG(("Audio Info: "
|
LOG(("Audio Info: "
|
||||||
"-receiveWakeNote: received, scheduling detach from audio device"));
|
"-receiveWakeNote: received, scheduling detach from audio device"));
|
||||||
Media::Audio::ScheduleDetachFromDeviceSafe();
|
Media::Audio::ScheduleDetachFromDeviceSafe();
|
||||||
|
|
||||||
|
Core::App().settings().setSystemDarkMode(Platform::IsDarkMode());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setWatchingMediaKeys:(bool)watching {
|
- (void) setWatchingMediaKeys:(bool)watching {
|
||||||
|
|
|
@ -1419,6 +1419,20 @@ void SetupSupport(
|
||||||
controller->session().saveSettingsDelayed();
|
controller->session().saveSettingsDelayed();
|
||||||
}, inner->lifetime());
|
}, inner->lifetime());
|
||||||
|
|
||||||
|
inner->add(
|
||||||
|
object_ptr<Ui::Checkbox>(
|
||||||
|
inner,
|
||||||
|
"Send all messages without sound",
|
||||||
|
controller->session().settings().supportAllSilent(),
|
||||||
|
st::settingsCheckbox),
|
||||||
|
st::settingsSendTypePadding
|
||||||
|
)->checkedChanges(
|
||||||
|
) | rpl::start_with_next([=](bool checked) {
|
||||||
|
controller->session().settings().setSupportAllSilent(
|
||||||
|
checked);
|
||||||
|
controller->session().saveSettingsDelayed();
|
||||||
|
}, inner->lifetime());
|
||||||
|
|
||||||
AddSkip(inner, st::settingsCheckboxesSkip);
|
AddSkip(inner, st::settingsCheckboxesSkip);
|
||||||
|
|
||||||
AddSubsectionTitle(inner, rpl::single(qsl("Load chats for a period")));
|
AddSubsectionTitle(inner, rpl::single(qsl("Load chats for a period")));
|
||||||
|
|
Loading…
Add table
Reference in a new issue