MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / restoreJobs

Method restoreJobs

tmp_admin/tmp_admin.ts:805–843  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

803 await db.read();
804 if (!db.data) db.data = { jobs: {} };
805 if (!db.data.jobs) db.data.jobs = {};
806
807 const removedKeys: string[] = [];
808 for (const [key, stored] of Object.entries(db.data.jobs)) {
809 try {
810 const channel = deserializeChannel(stored.channel);
811 const userEntity = deserializeUser(stored.user);
812 this.scheduleExpiry(key, {
813 client: runtime.client,
814 channel,
815 chatKey: stored.chatKey,
816 peerId: toSendPeer(channel),
817 userEntity,
818 userId: stored.userId,
819 userDisplay: stored.userDisplay,
820 originalRank: stored.originalRank || "",
821 replyToMsgId: stored.replyToMsgId,
822 expiresAt: stored.expiresAt,
823 retryCount: stored.retryCount || 0,
824 });
825 } catch (error) {
826 console.error(`[tmp_admin] 跳过无法恢复的任务 ${key}:`, error);
827 removedKeys.push(key);
828 }
829 }
830
831 if (removedKeys.length > 0) {
832 await this.mutateDb((data) => {
833 for (const key of removedKeys) delete data.jobs[key];
834 });
835 }
836 }
837
838 private async demoteAdmin(client: any, channel: any, userEntity: any, originalRank?: string): Promise<void> {
839 await client.invoke(
840 new Api.channels.EditAdmin({
841 channel,
842 userId: userEntity,
843 adminRights: new Api.ChatAdminRights({}),
844 rank: originalRank || "",
845 })
846 );

Callers 1

constructorMethod · 0.95

Calls 7

getDbMethod · 0.95
scheduleExpiryMethod · 0.95
mutateDbMethod · 0.95
deserializeChannelFunction · 0.85
deserializeUserFunction · 0.85
toSendPeerFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected