Merge branch 'admin-blocks' into 'main'

storeMiddleware: pass through admin UserStore

See merge request soapbox-pub/ditto!197
This commit is contained in:
Alex Gleason 2024-04-30 18:49:11 +00:00
commit 19ba7e74d6
1 changed files with 4 additions and 2 deletions

View File

@ -1,16 +1,18 @@
import { AppMiddleware } from '@/app.ts'; import { AppMiddleware } from '@/app.ts';
import { Conf } from '@/config.ts';
import { UserStore } from '@/storages/UserStore.ts'; import { UserStore } from '@/storages/UserStore.ts';
import { eventsDB } from '@/storages.ts'; import { eventsDB } from '@/storages.ts';
/** Store middleware. */ /** Store middleware. */
const storeMiddleware: AppMiddleware = async (c, next) => { const storeMiddleware: AppMiddleware = async (c, next) => {
const pubkey = c.get('pubkey'); const pubkey = c.get('pubkey');
const adminStore = new UserStore(Conf.pubkey, eventsDB);
if (pubkey) { if (pubkey) {
const store = new UserStore(pubkey, eventsDB); const store = new UserStore(pubkey, adminStore);
c.set('store', store); c.set('store', store);
} else { } else {
c.set('store', eventsDB); c.set('store', adminStore);
} }
await next(); await next();
}; };