Skip to content

Commit

Permalink
Telegram mtproto update
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdicarlo committed Aug 8, 2022
1 parent 291f538 commit 886daaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions electron-app/src/server/websites/telegram/telegram.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MTProto } from '@mtproto/core';
const MTProtoClass = require('@mtproto/core');
import { MTProto } from '@mtproto/core'
import { Injectable } from '@nestjs/common';
import {
DefaultOptions,
Expand Down Expand Up @@ -175,10 +176,12 @@ export class Telegram extends Website {

if (appId && appHash && phoneNumber) {
if (!this.instances[appId]) {
this.instances[appId] = new MTProto({
this.instances[appId] = new MTProtoClass({
api_id: Number(appId),
api_hash: appHash,
customLocalStorage: new TelegramStorage(appId),
storageOptions: {
instance: new TelegramStorage(appId)
},
});

// COMMENTED OUT SINCE IT MIGHT BE BETTER TO CATCH THIS AND SET DURING AUTH TIME
Expand Down
4 changes: 2 additions & 2 deletions electron-app/src/server/websites/telegram/telegram.storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export class TelegramStorage {
return join(BASE_DIRECTORY, 'auth', 'telegram', `${this.name}.json`);
}

getItem(key: string): Promise<any> {
get(key: string): Promise<any> {
return this.storage[key];
}

setItem(key: string, value: any): Promise<any> {
set(key: string, value: any): Promise<any> {
this.storage[key] = value;
return writeJSON(this.getFileName(), this.storage, { spaces: 1 }).then(() => this.storage[key]);
}
Expand Down

0 comments on commit 886daaa

Please sign in to comment.