Skip to content

Commit

Permalink
1.9.5 (425)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Jan 20, 2025
1 parent 21df884 commit 8b059ce
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 68 deletions.
8 changes: 4 additions & 4 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Nicegram/NGPersonality/Sources/CollectContactsActivity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ private let collectContactsActivityUseCase = container.collectContactsActivityUs

public func collectContactsActivity(
with userId: Int64,
count: Int,
completion: @escaping () -> Void = {}
count: Int
) {
guard checkPreferencesStateUseCase(with: userId, personality: .contactsActivity(.empty)) else { return }

Task {
await collectContactsActivityUseCase(with: userId, count: count)
completion()
}
}
95 changes: 37 additions & 58 deletions Nicegram/NGPersonality/Sources/CollectInfluencerScore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,48 +41,37 @@ private func influencerScore(
with context: AccountContext
) -> Signal<(Int32, Int32, Int32, Int32, Int32, Int32), NoError> {
dialogs(with: context)
|> mapToSignal { dialogs -> Signal<[Api.messages.ChatFull?], NoError> in
|> map { dialogs -> [(PeerId.Namespace, Bool, Int32)] in
switch dialogs {
case let .dialogs(_, _, chats, _):
return fullChannels(with: context, chats: chats)
return chats.compactMap { information(from: $0) }
case let .dialogsSlice(_, _, _, chats, _):
return fullChannels(with: context, chats: chats)
default: return .single([])
return chats.compactMap { information(from: $0) }
default: return []
}
}
|> map { fullChannels -> (Int32, Int32, Int32, Int32, Int32, Int32) in
|> map { chats -> (Int32, Int32, Int32, Int32, Int32, Int32) in
var ownerChannelCount: Int32 = 0
var ownerChannelParticipantsCount: Int32 = 0
var ownerGroupCount: Int32 = 0
var ownerGroupParticipantsCount: Int32 = 0

var groupCount: Int32 = 0
var groupParticipantsCount: Int32 = 0

fullChannels.forEach { chatFull in
switch chatFull {
case let .chatFull(fullChat, _, _):
switch fullChat {
case let .channelFull(flags, _, _, _, participantsCount, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
let channelFlags = TelegramChannelFlags(rawValue: flags)
if channelFlags.contains(.isCreator) {
if channelFlags.contains(.isMegagroup) ||
channelFlags.contains(.isGigagroup) {
ownerGroupCount += 1
ownerGroupParticipantsCount += (participantsCount ?? 0)
} else {
ownerChannelCount += 1
ownerChannelParticipantsCount += (participantsCount ?? 0)
}
}
if channelFlags.contains(.isMegagroup) ||
channelFlags.contains(.isGigagroup) {
groupCount += 1
groupParticipantsCount += (participantsCount ?? 0)
}
default: break

chats.forEach { chat in
if chat.0 == Namespaces.Peer.CloudChannel {
if chat.1 {
ownerChannelCount += 1
ownerChannelParticipantsCount += chat.2
}
default: break
} else if chat.0 == Namespaces.Peer.CloudGroup {
if chat.1 {
ownerGroupCount += 1
ownerGroupParticipantsCount += chat.2
}
groupCount += 1
groupParticipantsCount += chat.2
}
}

Expand All @@ -97,35 +86,6 @@ private func influencerScore(
}
}

private func fullChannels(
with context: AccountContext,
chats: [Api.Chat]
) -> Signal<[Api.messages.ChatFull?], NoError> {
combineLatest(
chats.compactMap { chat in
switch chat {
case let .channel(_, _, id, accessHash, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _):
return fullChannel(with: context, channelId: id, accessHash: accessHash ?? 0)
default: return nil
}
}
)
}

private func fullChannel(
with context: AccountContext,
channelId: Int64,
accessHash: Int64
) -> Signal<Api.messages.ChatFull?, NoError> {
context.account.network.request(Api.functions.channels.getFullChannel(
channel: .inputChannel(channelId: channelId, accessHash: accessHash)
))
|> map(Optional.init)
|> `catch` { error -> Signal<Api.messages.ChatFull?, NoError> in
return .single(nil)
}
}

private func dialogs(
with context: AccountContext
) -> Signal<Api.messages.Dialogs?, NoError> {
Expand All @@ -143,3 +103,22 @@ private func dialogs(
return .single(nil)
}
}

private func information(from chat: Api.Chat) -> (PeerId.Namespace, Bool, Int32)? {
switch chat {
case let .chat(flags, _, _, _, participantsCount, _, _, _, _, _):
let isCreator = (flags & (1 << 0)) != 0
return (Namespaces.Peer.CloudGroup, isCreator, participantsCount)
case let .channel(flags, _, _, _, _, _, _, _, _, _, _, _, participantsCount, _, _, _, _, _, _, _, _):
let isCreator = (flags & (1 << 0)) != 0

var type = Namespaces.Peer.CloudChannel
if (flags & Int32(1 << 8)) != 0 {
type = Namespaces.Peer.CloudGroup
}

return (type, isCreator, participantsCount ?? 0)
case .chatEmpty, .chatForbidden, .channelForbidden:
return nil
}
}
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"location" : "[email protected]:mobyrix/nicegram-wallet-ios.git",
"state" : {
"branch" : "develop",
"revision" : "a35e6f8e55500f7522bbfc9c551c2fbe08b21fea"
"revision" : "0814446b00d6c35271e38ae798eeaf8c871d74cf"
}
},
{
Expand Down Expand Up @@ -356,8 +356,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/trustwallet/wallet-core.git",
"state" : {
"revision" : "ed9152aa17a5ab2f6b9ecd015ac2c334a6888791",
"version" : "4.2.2"
"revision" : "23ae9525ed3bd28a010d6cdd78e39955b1b2cdef",
"version" : "4.2.3"
}
},
{
Expand Down

0 comments on commit 8b059ce

Please sign in to comment.