mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 19:14:52 +01:00
Split keys out of stored data types
This commit is contained in:
parent
f5943ced97
commit
bef02d238f
@ -24,13 +24,14 @@ function encodeKey(roomId: string, sessionId: string, messageIndex: number | str
|
||||
interface GroupSessionDecryption {
|
||||
eventId: string;
|
||||
timestamp: number;
|
||||
key: string;
|
||||
}
|
||||
|
||||
export class GroupSessionDecryptionStore {
|
||||
private _store: Store<GroupSessionDecryption>;
|
||||
type GroupSessionEntry = GroupSessionDecryption & { key: string }
|
||||
|
||||
constructor(store: Store<GroupSessionDecryption>) {
|
||||
export class GroupSessionDecryptionStore {
|
||||
private _store: Store<GroupSessionEntry>;
|
||||
|
||||
constructor(store: Store<GroupSessionEntry>) {
|
||||
this._store = store;
|
||||
}
|
||||
|
||||
@ -39,8 +40,8 @@ export class GroupSessionDecryptionStore {
|
||||
}
|
||||
|
||||
set(roomId: string, sessionId: string, messageIndex: number, decryption: GroupSessionDecryption): void {
|
||||
decryption.key = encodeKey(roomId, sessionId, messageIndex);
|
||||
this._store.put(decryption);
|
||||
(decryption as GroupSessionEntry).key = encodeKey(roomId, sessionId, messageIndex);
|
||||
this._store.put(decryption as GroupSessionEntry);
|
||||
}
|
||||
|
||||
removeAllForRoom(roomId: string): Promise<undefined> {
|
||||
|
@ -20,15 +20,18 @@ export function encodeScopeTypeKey(scope: string, type: string): string {
|
||||
return `${scope}|${type}`;
|
||||
}
|
||||
|
||||
interface Operation {
|
||||
interface BaseOperation {
|
||||
id: string;
|
||||
type: string;
|
||||
scope: string;
|
||||
userIds: string[];
|
||||
scopeTypeKey: string;
|
||||
roomKeyMessage: RoomKeyMessage;
|
||||
}
|
||||
|
||||
type OperationType = { type: "share_room_key"; roomKeyMessage: RoomKeyMessage; }
|
||||
|
||||
type Operation = BaseOperation & OperationType
|
||||
|
||||
type OperationEntry = Operation & { scopeTypeKey: string; }
|
||||
|
||||
interface RoomKeyMessage {
|
||||
room_id: string;
|
||||
session_id: string;
|
||||
@ -38,9 +41,9 @@ interface RoomKeyMessage {
|
||||
}
|
||||
|
||||
export class OperationStore {
|
||||
private _store: Store<Operation>;
|
||||
private _store: Store<OperationEntry>;
|
||||
|
||||
constructor(store: Store<Operation>) {
|
||||
constructor(store: Store<OperationEntry>) {
|
||||
this._store = store;
|
||||
}
|
||||
|
||||
@ -62,12 +65,12 @@ export class OperationStore {
|
||||
}
|
||||
|
||||
add(operation: Operation): void {
|
||||
operation.scopeTypeKey = encodeScopeTypeKey(operation.scope, operation.type);
|
||||
this._store.add(operation);
|
||||
(operation as OperationEntry).scopeTypeKey = encodeScopeTypeKey(operation.scope, operation.type);
|
||||
this._store.add(operation as OperationEntry);
|
||||
}
|
||||
|
||||
update(operation: Operation): void {
|
||||
this._store.put(operation);
|
||||
this._store.put(operation as OperationEntry);
|
||||
}
|
||||
|
||||
remove(id: string): Promise<undefined> {
|
||||
|
Loading…
Reference in New Issue
Block a user