1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-04 02:17:51 +01:00
Telegram/Watch/Bridge/TGBridgePeerNotificationSettings+TGPeerNotificationSettings.m
2016-02-25 01:03:51 +01:00

29 lines
1.1 KiB
Objective-C

#import "TGBridgePeerNotificationSettings+TGPeerNotificationSettings.h"
#import "TGPeerNotificationSettingsSignals.h"
@implementation TGBridgePeerNotificationSettings (TGPeerNotificationSettings)
+ (TGBridgePeerNotificationSettings *)peerNotificationSettingsWithTGPeerNotificationSettings:(TGPeerNotificationSettings *)settings currentTime:(int32_t)currentTime
{
int32_t muteFor = MAX(0, settings.muteUntil - currentTime);
TGBridgePeerNotificationSettings *bridgeSettings = [[TGBridgePeerNotificationSettings alloc] init];
bridgeSettings.muteFor = muteFor;
return bridgeSettings;
}
+ (TGPeerNotificationSettings *)tgPeerNotificationSettingsWithpeerNotificationSettingsWithBridgePeerNotificationSettings:(TGBridgePeerNotificationSettings *)bridgeSettings currentTime:(int32_t)currentTime
{
int32_t muteFor = bridgeSettings.muteFor;
int32_t muteUntil = 0;
if (muteFor == INT_MAX)
muteUntil = INT_MAX;
else if (muteFor > 0)
muteUntil = bridgeSettings.muteFor + currentTime;
return [[TGPeerNotificationSettings alloc] initWithMuteUntil:muteUntil];
}
@end