Skip to content

Commit

Permalink
replace filterChannelsToAllowed with filterResourcesToAllowed (razee-…
Browse files Browse the repository at this point in the history
…io#1340)

* replace filterChannelsToAllowed with filterResourcesToAllowed

* query for channels

* add channel obj to gql

* check for channel uuid

* npm update

---------

Co-authored-by: ethanstjohn <[email protected]>
  • Loading branch information
ethanstjohn and ethanstjohn authored Sep 25, 2023
1 parent 8f1088e commit 60cef22
Show file tree
Hide file tree
Showing 4 changed files with 565 additions and 516 deletions.
1 change: 1 addition & 0 deletions app/apollo/test/subscriptions.fga.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ describe('subscription graphql test suite', () => {
expect(subscription.groupObjs[0].uuid).to.equal(testGroup1.uuid);
expect(subscription.versionObj).to.exist;
expect(subscription.versionObj.name).to.equal( testVersion1.name );
expect(subscription.channel.uuid).to.equal(testSubscription1.channel_uuid);
} catch (error) {
console.error(JSON.stringify({'API response:': response && response.data ? response.data : 'unexpected response'}, null, 3));
console.error('Test failure, error: ', error);
Expand Down
6 changes: 6 additions & 0 deletions app/apollo/test/subscriptionsApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ const subscriptionsFunc = grahqlUrl => {
}
}
}
channel {
uuid
name
tags
contentType
}
custom
tags
}
Expand Down
4 changes: 2 additions & 2 deletions app/apollo/utils/applyQueryFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

const _ = require('lodash');
const { getGroupConditions, filterChannelsToAllowed, filterResourcesToAllowed } = require('../resolvers/common');
const { getGroupConditions, filterResourcesToAllowed } = require('../resolvers/common');
// RBAC Sync
const { ACTIONS, TYPES, CLUSTER_STATUS, CLUSTER_IDENTITY_SYNC_STATUS } = require('../models/const');
const { NotFoundError } = require ('../resolvers/common');
Expand Down Expand Up @@ -380,7 +380,7 @@ const applyQueryFieldsToSubscriptions = async(subs, queryFields={}, args, contex
if(queryFields.channel){
const channelUuids = _.uniq(_.map(subs, 'channelUuid'));
let channels = await models.Channel.find({ uuid: { $in: channelUuids } }).lean({ virtuals: true });
channels = await filterChannelsToAllowed(me, orgId, ACTIONS.READ, TYPES.CHANNEL, channels, context);
channels = await filterResourcesToAllowed(me, orgId, ACTIONS.READ, TYPES.CHANNEL, channels, context);

await applyQueryFieldsToChannels(channels, queryFields.channel, args, context);

Expand Down
Loading

0 comments on commit 60cef22

Please sign in to comment.