Access category/group permission in javascript

Dear all,

I’m trying to make a component that would display in the category banner what are the groups that can read this category.

I’m imagining something like that:

for (g of groups) {
    if (g.permission(category) > 0) {
       display(g);
    }
}

In order to do that, and by looking at other people’s code, I found out how to access the variable category, which was easy:

const container = Discourse.__container__;
const controller = container.lookup('controller:navigation/category');
category = controller.get("category");

I’ve found out a way to access the group list:

const container = Discourse.__container__;
const controller = container.lookup('controller:navigation/category');
groups = controller.get("site").get("groups");

But I can’t find a way to check compute/deduce if a group can access a category.
category.permission does not give this information and each group has only 5 properties: the flair infos, the name and the id.

Can anyone give me a hint where I can read the information so that I can check for each group if it can access the category?

Thanks in advance.

1 Like