Major API Update: Roles and Global Roles Revamped

Intro

If you’re reading this and you are not an extension and/or bot developer, this will most likely not apply to you and it’s not important for you to read this. if you do maintain any code that uses plug.dj, please read this to make sure your permissions don’t go all crazy on you..

Current Situation/Issue

You might have already heard, we are planning to add new roles to plug.dj. Right now, there is no space to squeeze a role into. We have constants for the current roles from 0 to 5 in ascending order.

{
    0: “User”,
    1: “(Resident) DJ”,
    2: “Bouncer”,
    3: “Manager”,
    4: “Co-Host”,
    5: “Host”
}

And gRoles:

{
    3: “Brand Ambassador”,
    5: “Admin”
}

The same goes for our global roles (Brand Ambassador, Admin). If you use code to check for BAs/Admins you might have come across the gRole property. This stands for global role. You’ll know that for a Brand Ambassador, the gRole property is set to 3 and for an Admin it’s 5. This essentially means that a Brand Ambassador has the permissions of a Manager globally (in every community) and Admin has Host everywhere on the site.

Chances are in both our code and your code you will compare these roles by using the constants to compare permissions. For example, if the role is higher or equal to 2 (Bouncer), you let a user perform a certain action (eg. ban via your bot). If we would add another role, we’d have to add role 6. This would mean that they would have the most permissions out of every role that exists.

New Situation/Solution

We decided to multiply all existing roles by 1000. The new scheme will look like this:

{
    0:        “User”,
    1000: “(Resident) DJ”,
    2000: “Bouncer”,
    3000: “Manager”,
    4000: “Co-Host”,
    5000: “Host”
}

And gRoles:

{
    3000: “Brand Ambassador”,
    5000: “Admin”
}

This means we have room for 999 other roles in between the current roles that we have. This allows for much more flexibility and not very much code change for you and me.

If you use our front-end JavaScript API, chances are you don’t have to change anything if you use the constants we have set (API.ROLE.DJ, API.ROLE.BOUNCER, API.ROLE.MANAGER, API.ROLE.COHOST, API.ROLE.HOST). They will be updated once this update is released and your code will continue to work. If you chose to use the integers to compare instead of the constants, you will have to change your code to make sure chaos is avoided once this update is released.

 

Please email updates+roleupdate@plug.dj if this update is manageable for you to be prepared for your bots and extensions/scripts before Tuesday, September 19th or if you’d like to be added to our developer mailing list.

3 thoughts on “Major API Update: Roles and Global Roles Revamped

  1. Cameron

    Seems weird to leave user as 0. If the point of this change is to add flexibility to roles, do you really think there will never be a role below user?

    Anyway, thanks for the update. Looking forward to the new roles.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *