Fix channel default mute behavior (#6)
This commit is contained in:
parent
0cd33fa0a2
commit
bd4fd3ec36
|
@ -101,17 +101,19 @@ namespace tgcli {
|
|||
|
||||
return history;
|
||||
}
|
||||
|
||||
|
||||
public static bool IsMuted(Chat c) {
|
||||
if (c.NotificationSettings.MuteFor == 0 && !c.NotificationSettings.UseDefaultMuteFor)
|
||||
return false;
|
||||
|
||||
NotificationSettingsScope scope = c.Type switch {
|
||||
ChatType.ChatTypeBasicGroup => new NotificationSettingsScope.NotificationSettingsScopeGroupChats(),
|
||||
ChatType.ChatTypeSupergroup => new NotificationSettingsScope.NotificationSettingsScopeGroupChats(),
|
||||
ChatType.ChatTypePrivate => new NotificationSettingsScope.NotificationSettingsScopePrivateChats(),
|
||||
ChatType.ChatTypeSecret => new NotificationSettingsScope.NotificationSettingsScopePrivateChats(),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
ChatType.ChatTypeSupergroup t => t.IsChannel
|
||||
? new NotificationSettingsScope.NotificationSettingsScopeChannelChats()
|
||||
: new NotificationSettingsScope.NotificationSettingsScopeGroupChats(),
|
||||
ChatType.ChatTypePrivate => new NotificationSettingsScope.NotificationSettingsScopePrivateChats(),
|
||||
ChatType.ChatTypeSecret => new NotificationSettingsScope.NotificationSettingsScopePrivateChats(),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
return client.GetScopeNotificationSettingsAsync(scope).Result.MuteFor != 0;
|
||||
|
@ -123,9 +125,7 @@ namespace tgcli {
|
|||
var response = client.ExecuteAsync(new GetChats { Limit = int.MaxValue }).Result;
|
||||
output.AddRange(all
|
||||
? response.ChatIds.Select(GetChat).Where(c => c.UnreadCount > 0 || c.IsMarkedAsUnread).ToList()
|
||||
: response.ChatIds.Select(GetChat)
|
||||
.Where(c => (c.UnreadCount > 0 || c.IsMarkedAsUnread) && !IsMuted(c))
|
||||
.ToList());
|
||||
: response.ChatIds.Select(GetChat).Where(c => (c.UnreadCount > 0 || c.IsMarkedAsUnread) && !IsMuted(c)).ToList());
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue