Merge pull request #935 from podemos-info/api

API Improvements (v2)
This commit is contained in:
Tomas Bures 2020-08-26 11:58:48 +02:00 committed by GitHub
commit 613a6fb1f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 183 additions and 51 deletions

View file

@ -866,13 +866,14 @@ async function getListsWithEmail(context, email) {
// FIXME - this methods is rather suboptimal if there are many lists. It quite needs permission caching in shares.js
return await knex.transaction(async tx => {
const lsts = await tx('lists').select(['id', 'cid', 'name']);
const lsts = await tx('lists').select(['id', 'cid', 'name', 'description']);
const result = [];
for (const list of lsts) {
await shares.enforceEntityPermissionTx(tx, context, 'list', list.id, 'viewSubscriptions');
const entity = await tx(getSubscriptionTableName(list.id)).where('hash_email', hashEmail(email)).whereNotNull('email').first();
if (entity) {
list.status=entity.status;
result.push(list);
}
}