(
client: TelegramClient,
chatId: any,
userId: number,
participant?: any
)
| 799 | |
| 800 | static async getManagedGroups( |
| 801 | client: TelegramClient |
| 802 | ): Promise<ManagedGroup[]> { |
| 803 | // v5: 用 dialog.entity.creator/adminRights 本地过滤(零 RPC)。 |
| 804 | // v4 对每群 GetParticipant,易假阴性 → refresh 统计为 0;空数组也会被当成有效缓存。 |
| 805 | const cached = await this.cache.get("managed_groups_v5"); |
| 806 | if (cached && Array.isArray(cached) && cached.length > 0) return cached; |
| 807 | |
| 808 | const groups: ManagedGroup[] = []; |
| 809 | |
| 810 | try { |
| 811 | const dialogs = await this.getAllManageableDialogs(client); |
| 812 | |
| 813 | let skippedNoRights = 0; |
| 814 | for (const dialog of dialogs || []) { |
| 815 | if (!(dialog.isChannel || dialog.isGroup)) continue; |
| 816 | if (!this.dialogHasManageRights(dialog)) { |
| 817 | skippedNoRights++; |
| 818 | continue; |
| 819 | } |
| 820 | const isChannel = !(dialog.isGroup && !dialog.isChannel); |
| 821 | const rawHash = isChannel ? dialog.entity?.accessHash : undefined; |
| 822 | const accessHash = rawHash != null ? String(rawHash) : undefined; |
no test coverage detected