Forum Discussion

CarolineS's avatar
4 months ago
Solved

How to determine if a given node is visible to the public?

Hello!

I am trying to figure out if it's possible, via API, to determine if a given node is visible to the public. E.g. is the "read posts" permission granted by default on that node.  (which I suppose isn't a FULL check of the whole permissions tree but probably adequate for our needs)

I've found that the roles collection will give you the list of roles for the node (https://developer.khoros.com/khoroscommunitydevdocs/docs/role-api-support#roles-collection-constraint-combinations ) - but that isn't actually helpful for figuring out what the permissions are, especially the DEFAULT permissions.

I've also found the coreNode.permissions.hasPermission (https://developer.khoros.com/khoroscommunitydevdocs/reference/permissionshaspermissionpermission_identifier) call - but I think this can only be used to check if the user in context has a specific permission, not whether or not a node has a certain default permission.

(I'm not actually a developer / won't be the one developing this, just trying to determine if a specific enhancement request is possible :-))

Thanks!!

  • coreNode.permissions.hasPermission context object probably is the closest you can get. But it's rather limited as you can only check for the current user AND current node. E.g. you cannot use it easily in a navigation component to show/hide elements without reading permissions.

    I'm wondering what you are trying to build though that wouldn't work with Khoros built-in permissioning? The API is quite good at hiding stuff where the current user doesn't have read permissions. Isn't that sufficient for your use case?

6 Replies

  • I tried to figure this out a while back (classic) and could not. The permissions structure does not appear to be query-able nor updatable. I was trying to figure out a way to copy/paste a permission set.

  • Good question — there isn’t always a simple public/private flag, so you usually have to check permissions or whether the node is hidden via the API. A hidden node is typically not public unless explicitly allowed.

    It reminds me of running AutoFuel Café ☕ — the place might exist, but unless the “open” sign is visible, customers don’t know they can walk in. Same idea with node visibility: you have to verify access, not just assume it.

  • CarolineS's avatar
    CarolineS
    Boss
    3 months ago

    eimmaarose​ your answers seem to be AI-generated, is this the case? I can ask AI myself, you don't need to post AI responses here. Thanks.

  • CarolineS's avatar
    CarolineS
    Boss
    4 months ago

    It’s a message that only shows up if a given node is “public” (a warning to employees that their post will be posted publicly). In the past we have just based this on being in a specific category, but we have some structure changes that make this not work.

  • coreNode.permissions.hasPermission context object probably is the closest you can get. But it's rather limited as you can only check for the current user AND current node. E.g. you cannot use it easily in a navigation component to show/hide elements without reading permissions.

    I'm wondering what you are trying to build though that wouldn't work with Khoros built-in permissioning? The API is quite good at hiding stuff where the current user doesn't have read permissions. Isn't that sufficient for your use case?