(msg: Api.Message)
| 822 | |
| 823 | const getGroupedMessageIds = async (msg: Api.Message): Promise<number[]> => { |
| 824 | if (!msg?.client) return []; |
| 825 | const rawGroupedId = (msg as any).groupedId; |
| 826 | const groupedId = rawGroupedId ? rawGroupedId.toString() : undefined; |
| 827 | if (!groupedId) return []; |
| 828 | |
| 829 | const peer = msg.chatId || msg.peerId; |
| 830 | const ids: number[] = []; |
| 831 | |
| 832 | for await (const m of msg.client.iterMessages(peer, { limit: 50 })) { |
| 833 | if (!(m instanceof Api.Message)) continue; |
| 834 | const g = (m as any).groupedId; |
| 835 | if (!g) continue; |
| 836 | if (g.toString() !== groupedId) continue; |
| 837 | ids.push(Number(m.id)); |
| 838 | } |
| 839 | |
| 840 | if (!ids.includes(Number(msg.id))) ids.push(Number(msg.id)); |
| 841 | |
| 842 | return Array.from(new Set(ids)).sort((a, b) => a - b); |
| 843 | }; |
| 844 | |
| 845 | const deleteMessageOrGroup = async (msg: Api.Message): Promise<void> => { |
| 846 | try { |
| 847 | if (!msg?.client) return; |
no outgoing calls
no test coverage detected