forked from mystiq/hydrogen-web
add outbound group session storage
This commit is contained in:
parent
6bc30bb824
commit
be4d887178
4 changed files with 42 additions and 1 deletions
|
@ -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) => {
|
||||||
|
|
|
@ -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) {
|
||||||
|
@ -100,7 +101,10 @@ export class Transaction {
|
||||||
get inboundGroupSessions() {
|
get inboundGroupSessions() {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
29
src/matrix/storage/idb/stores/OutboundGroupSessionStore.js
Normal file
29
src/matrix/storage/idb/stores/OutboundGroupSessionStore.js
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue