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",
"olmSessions",
"inboundGroupSessions",
"outboundGroupSessions",
]);
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 {OlmSessionStore} from "./stores/OlmSessionStore.js";
import {InboundGroupSessionStore} from "./stores/InboundGroupSessionStore.js";
import {OutboundGroupSessionStore} from "./stores/OutboundGroupSessionStore.js";
export class Transaction {
constructor(txn, allowedStoreNames) {
@ -100,7 +101,10 @@ export class Transaction {
get inboundGroupSessions() {
return this._store("inboundGroupSessions", idbStore => new InboundGroupSessionStore(idbStore));
}
get outboundGroupSessions() {
return this._store("outboundGroupSessions", idbStore => new OutboundGroupSessionStore(idbStore));
}
complete() {
return txnAsPromise(this._txn);
}

View file

@ -12,6 +12,7 @@ export const schema = [
createIdentityStores,
createOlmSessionStore,
createInboundGroupSessionsStore,
createOutboundGroupSessionsStore,
];
// TODO: how to deal with git merge conflicts of this array?
@ -82,3 +83,9 @@ function createOlmSessionStore(db) {
function createInboundGroupSessionsStore(db) {
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);
}
}