Esempio n. 1
0
        private async Task GetUserSettings()
        {
            if (_getInProgress)
            {
                return;
            }

            _getInProgress = true;
            // FIXME: catch exception

            await TelegramSession.Instance.Established;

            try {
                PeerNotifySettings settings =
                    await
                    TelegramSession.Instance.Api.account_getNotifySettings(
                        TL.inputNotifyPeer(TL.inputPeerContact(Id)));


                switch (settings.Constructor)
                {
                case Constructor.peerNotifySettings:
                    UpdatePeerNotifySettings(settings as PeerNotifySettingsConstructor);
                    break;

                case Constructor.peerNotifySettingsEmpty:
                    logger.error("Unable to get USER settings: Constructor.peerNotifySettingsEmpty");
                    break;
                }
            } catch (MTProtoException ex) {
                logger.error("GetUserSettings Exception");
            }

            _getInProgress = false;
        }
Esempio n. 2
0
        private async Task UpdateUserSettings()
        {
            if (_updateInProgress)
            {
                return;
            }

            // LOCK ON THIS
            _updateInProgress = true;

            logger.debug("Synchronizing settings");
            try {
                InputPeerNotifySettings newSettings = TL.inputPeerNotifySettings(peerNotifySettings.mute_until,
                                                                                 peerNotifySettings.sound, peerNotifySettings.show_previews, peerNotifySettings.events_mask);

                // FIXME: catch exception, process BOOl error
                bool update = await TelegramSession.Instance.Api.account_updateNotifySettings(TL.inputNotifyPeer
                                                                                                  (TL.inputPeerContact(Id)), newSettings);

                logger.debug("Synchronized settings: " + update);
            }
            catch (MTProtoException ex) {
                logger.error("UpdateUserSettings Exception");
            }
            // UNLOCK ON THIS
            _updateInProgress = false;
        }