add outbound group session storage

This commit is contained in:
Bruno Windels 2020-09-03 17:49:20 +02:00
parent 6bc30bb824
commit be4d887178
4 changed files with 42 additions and 1 deletions

View File

@ -26,6 +26,7 @@ export const STORE_NAMES = Object.freeze([
"deviceIdentities", "deviceIdentities",
"olmSessions", "olmSessions",
"inboundGroupSessions", "inboundGroupSessions",
"outboundGroupSessions",
]); ]);
export const STORE_MAP = Object.freeze(STORE_NAMES.reduce((nameMap, name) => { export const STORE_MAP = Object.freeze(STORE_NAMES.reduce((nameMap, name) => {

View File

@ -28,6 +28,7 @@ import {UserIdentityStore} from "./stores/UserIdentityStore.js";
import {DeviceIdentityStore} from "./stores/DeviceIdentityStore.js"; import {DeviceIdentityStore} from "./stores/DeviceIdentityStore.js";
import {OlmSessionStore} from "./stores/OlmSessionStore.js"; import {OlmSessionStore} from "./stores/OlmSessionStore.js";
import {InboundGroupSessionStore} from "./stores/InboundGroupSessionStore.js"; import {InboundGroupSessionStore} from "./stores/InboundGroupSessionStore.js";
import {OutboundGroupSessionStore} from "./stores/OutboundGroupSessionStore.js";
export class Transaction { export class Transaction {
constructor(txn, allowedStoreNames) { constructor(txn, allowedStoreNames) {
@ -101,6 +102,9 @@ export class Transaction {
return this._store("inboundGroupSessions", idbStore => new InboundGroupSessionStore(idbStore)); return this._store("inboundGroupSessions", idbStore => new InboundGroupSessionStore(idbStore));
} }
get outboundGroupSessions() {
return this._store("outboundGroupSessions", idbStore => new OutboundGroupSessionStore(idbStore));
}
complete() { complete() {
return txnAsPromise(this._txn); return txnAsPromise(this._txn);
} }

View File

@ -12,6 +12,7 @@ export const schema = [
createIdentityStores, createIdentityStores,
createOlmSessionStore, createOlmSessionStore,
createInboundGroupSessionsStore, createInboundGroupSessionsStore,
createOutboundGroupSessionsStore,
]; ];
// TODO: how to deal with git merge conflicts of this array? // TODO: how to deal with git merge conflicts of this array?
@ -82,3 +83,9 @@ function createOlmSessionStore(db) {
function createInboundGroupSessionsStore(db) { function createInboundGroupSessionsStore(db) {
db.createObjectStore("inboundGroupSessions", {keyPath: "key"}); db.createObjectStore("inboundGroupSessions", {keyPath: "key"});
} }
//v7
function createOutboundGroupSessionsStore(db) {
db.createObjectStore("outboundGroupSessions", {keyPath: "roomId"});
}

View File

@ -0,0 +1,29 @@
/*
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
export class OutboundGroupSessionStore {
constructor(store) {
this._store = store;
}
get(roomId) {
return this._store.get(roomId);
}
set(session) {
this._store.put(session);
}
}