diff --git a/src/matrix/storage/common.js b/src/matrix/storage/common.js index 76a60e66..473b8eb6 100644 --- a/src/matrix/storage/common.js +++ b/src/matrix/storage/common.js @@ -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) => { diff --git a/src/matrix/storage/idb/Transaction.js b/src/matrix/storage/idb/Transaction.js index fa862c08..8b42b0f7 100644 --- a/src/matrix/storage/idb/Transaction.js +++ b/src/matrix/storage/idb/Transaction.js @@ -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); } diff --git a/src/matrix/storage/idb/schema.js b/src/matrix/storage/idb/schema.js index 81a56991..2060cb39 100644 --- a/src/matrix/storage/idb/schema.js +++ b/src/matrix/storage/idb/schema.js @@ -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"}); +} + diff --git a/src/matrix/storage/idb/stores/OutboundGroupSessionStore.js b/src/matrix/storage/idb/stores/OutboundGroupSessionStore.js new file mode 100644 index 00000000..ef9224be --- /dev/null +++ b/src/matrix/storage/idb/stores/OutboundGroupSessionStore.js @@ -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); + } +}