mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
[WIP] Topics
This commit is contained in:
@@ -300,7 +300,7 @@ private enum ChannelPermissionsEntry: ItemListNodeEntry {
|
||||
case let .member(_, _, _, banInfo, _):
|
||||
var exceptionsString = ""
|
||||
if let banInfo = banInfo {
|
||||
for (rights, _) in allGroupPermissionList {
|
||||
for (rights, _) in internal_allPossibleGroupPermissionList {
|
||||
if !defaultBannedRights.contains(rights) && banInfo.rights.flags.contains(rights) {
|
||||
if !exceptionsString.isEmpty {
|
||||
exceptionsString.append(", ")
|
||||
@@ -352,11 +352,9 @@ func stringForGroupPermission(strings: PresentationStrings, right: TelegramChatB
|
||||
} else if right.contains(.banAddMembers) {
|
||||
return strings.Channel_BanUser_PermissionAddMembers
|
||||
} else if right.contains(.banPinMessages) {
|
||||
if isForum {
|
||||
return strings.Channel_EditAdmin_PermissionCreateTopics
|
||||
} else {
|
||||
return strings.Channel_EditAdmin_PermissionPinMessages
|
||||
}
|
||||
return strings.Channel_EditAdmin_PermissionPinMessages
|
||||
} else if right.contains(.banManageTopics) {
|
||||
return strings.Channel_EditAdmin_PermissionManageTopics
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
@@ -379,12 +377,14 @@ func compactStringForGroupPermission(strings: PresentationStrings, right: Telegr
|
||||
return strings.GroupPermission_NoAddMembers
|
||||
} else if right.contains(.banPinMessages) {
|
||||
return strings.GroupPermission_NoPinMessages
|
||||
} else if right.contains(.banManageTopics) {
|
||||
return strings.GroupPermission_NoManageTopics
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
public let allGroupPermissionList: [(TelegramChatBannedRightsFlags, TelegramChannelPermission)] = [
|
||||
private let internal_allPossibleGroupPermissionList: [(TelegramChatBannedRightsFlags, TelegramChannelPermission)] = [
|
||||
(.banSendMessages, .banMembers),
|
||||
(.banSendMedia, .banMembers),
|
||||
(.banSendGifs, .banMembers),
|
||||
@@ -392,9 +392,37 @@ public let allGroupPermissionList: [(TelegramChatBannedRightsFlags, TelegramChan
|
||||
(.banSendPolls, .banMembers),
|
||||
(.banAddMembers, .banMembers),
|
||||
(.banPinMessages, .pinMessages),
|
||||
(.banManageTopics, .manageTopics),
|
||||
(.banChangeInfo, .changeInfo)
|
||||
]
|
||||
|
||||
public func allGroupPermissionList(peer: EnginePeer) -> [(TelegramChatBannedRightsFlags, TelegramChannelPermission)] {
|
||||
if case let .channel(channel) = peer, channel.flags.contains(.isForum) {
|
||||
return [
|
||||
(.banSendMessages, .banMembers),
|
||||
(.banSendMedia, .banMembers),
|
||||
(.banSendGifs, .banMembers),
|
||||
(.banEmbedLinks, .banMembers),
|
||||
(.banSendPolls, .banMembers),
|
||||
(.banAddMembers, .banMembers),
|
||||
(.banPinMessages, .pinMessages),
|
||||
(.banManageTopics, .manageTopics),
|
||||
(.banChangeInfo, .changeInfo)
|
||||
]
|
||||
} else {
|
||||
return [
|
||||
(.banSendMessages, .banMembers),
|
||||
(.banSendMedia, .banMembers),
|
||||
(.banSendGifs, .banMembers),
|
||||
(.banEmbedLinks, .banMembers),
|
||||
(.banSendPolls, .banMembers),
|
||||
(.banAddMembers, .banMembers),
|
||||
(.banPinMessages, .pinMessages),
|
||||
(.banChangeInfo, .changeInfo)
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
let publicGroupRestrictedPermissions: TelegramChatBannedRightsFlags = [
|
||||
.banPinMessages,
|
||||
.banChangeInfo
|
||||
@@ -415,6 +443,8 @@ func groupPermissionDependencies(_ right: TelegramChatBannedRightsFlags) -> Tele
|
||||
return []
|
||||
} else if right.contains(.banPinMessages) {
|
||||
return []
|
||||
} else if right.contains(.banManageTopics) {
|
||||
return []
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
@@ -433,7 +463,7 @@ private func channelPermissionsControllerEntries(context: AccountContext, presen
|
||||
|
||||
entries.append(.permissionsHeader(presentationData.theme, presentationData.strings.GroupInfo_Permissions_SectionTitle))
|
||||
var rightIndex: Int = 0
|
||||
for (rights, correspondingAdminRight) in allGroupPermissionList {
|
||||
for (rights, correspondingAdminRight) in allGroupPermissionList(peer: .channel(channel)) {
|
||||
var enabled: Bool? = true
|
||||
if channel.addressName != nil && publicGroupRestrictedPermissions.contains(rights) {
|
||||
enabled = false
|
||||
@@ -482,7 +512,7 @@ private func channelPermissionsControllerEntries(context: AccountContext, presen
|
||||
|
||||
entries.append(.permissionsHeader(presentationData.theme, presentationData.strings.GroupInfo_Permissions_SectionTitle))
|
||||
var rightIndex: Int = 0
|
||||
for (rights, _) in allGroupPermissionList {
|
||||
for (rights, _) in allGroupPermissionList(peer: .legacyGroup(group)) {
|
||||
entries.append(.permission(presentationData.theme, rightIndex, stringForGroupPermission(strings: presentationData.strings, right: rights, isForum: false), !effectiveRightsFlags.contains(rights), rights, true))
|
||||
rightIndex += 1
|
||||
}
|
||||
@@ -586,7 +616,7 @@ public func channelPermissionsController(context: AccountContext, updatedPresent
|
||||
effectiveRightsFlags = effectiveRightsFlags.subtracting(groupPermissionDependencies(rights))
|
||||
} else {
|
||||
effectiveRightsFlags.insert(rights)
|
||||
for (right, _) in allGroupPermissionList {
|
||||
for (right, _) in allGroupPermissionList(peer: .channel(channel)) {
|
||||
if groupPermissionDependencies(right).contains(rights) {
|
||||
effectiveRightsFlags.insert(right)
|
||||
}
|
||||
@@ -616,7 +646,7 @@ public func channelPermissionsController(context: AccountContext, updatedPresent
|
||||
effectiveRightsFlags = effectiveRightsFlags.subtracting(groupPermissionDependencies(rights))
|
||||
} else {
|
||||
effectiveRightsFlags.insert(rights)
|
||||
for (right, _) in allGroupPermissionList {
|
||||
for (right, _) in allGroupPermissionList(peer: .legacyGroup(group)) {
|
||||
if groupPermissionDependencies(right).contains(rights) {
|
||||
effectiveRightsFlags.insert(right)
|
||||
}
|
||||
@@ -718,7 +748,7 @@ public func channelPermissionsController(context: AccountContext, updatedPresent
|
||||
guard let channel = view.peers[view.peerId] as? TelegramChannel else {
|
||||
return
|
||||
}
|
||||
for (listRight, permission) in allGroupPermissionList {
|
||||
for (listRight, permission) in allGroupPermissionList(peer: .channel(channel)) {
|
||||
if listRight == right {
|
||||
let text: String
|
||||
let presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
Reference in New Issue
Block a user