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