TTP -> MTP, A lot of other stuff #21
1 changed files with 15 additions and 3 deletions
commit
7d6080edbf
|
|
@ -132,15 +132,27 @@ function deserializeSessionState(value: unknown): MTPSessionState | null {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LocalMTPSessionStorage implements MTPSessionStorage {
|
class LocalMTPSessionStorage implements MTPSessionStorage {
|
||||||
|
private readonly load: <K extends "e2ee_sessions">(
|
||||||
|
key: K,
|
||||||
|
) => Promise<Record<string, unknown> | undefined>;
|
||||||
|
|
||||||
|
private readonly save: <K extends "e2ee_sessions">(
|
||||||
|
key: K,
|
||||||
|
value: Record<string, unknown>,
|
||||||
|
) => Promise<void>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly load: <K extends "e2ee_sessions">(
|
load: <K extends "e2ee_sessions">(
|
||||||
key: K,
|
key: K,
|
||||||
) => Promise<Record<string, unknown> | undefined>,
|
) => Promise<Record<string, unknown> | undefined>,
|
||||||
private readonly save: <K extends "e2ee_sessions">(
|
save: <K extends "e2ee_sessions">(
|
||||||
key: K,
|
key: K,
|
||||||
value: Record<string, unknown>,
|
value: Record<string, unknown>,
|
||||||
) => Promise<void>,
|
) => Promise<void>,
|
||||||
) {}
|
) {
|
||||||
|
this.load = load;
|
||||||
|
this.save = save;
|
||||||
|
}
|
||||||
|
|
||||||
async getSession(conversationId: string): Promise<MTPSessionState | null> {
|
async getSession(conversationId: string): Promise<MTPSessionState | null> {
|
||||||
const sessions = (await this.load("e2ee_sessions")) ?? {};
|
const sessions = (await this.load("e2ee_sessions")) ?? {};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue