Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarter room #2484

Merged
merged 17 commits into from
Mar 23, 2017
Merged

Smarter room #2484

merged 17 commits into from
Mar 23, 2017

Conversation

woogerboy21
Copy link
Contributor

Fix #2463

Added the ability for registered user - VIP/DONATOR/PRIVILEGED room.

Since the users privilege level does not have any type of tier concept to it, we can only compare the actual literal string value of the privilege level and check to see if a user is a part of the given privilege level to allow or deny them into a given room.

As explained when the privilege level concept was being introduced, we have admin level which is a bit comparison to allow the concept of admin > mod > reg > non-reg, but privilege level doesn't work like that. Its a sub category. So something like VIP !> DONATOR and vice versa.

With the logic in this PR a DONATOR for example can not enter a VIP room, nor can a VIP enter a DONATOR room, but we do compare admin level value(s) so regardless of admin/mod privilege levels they can enter the rooms. How ever an unregistered user is not allowed to enter the room if defined with the "vip" , "donator" or "privileged" database table privlevel"column value.

Clear as mud?

This PR adds a "privlevel" to the room so we can do easy comparisons between a rooms definition of "privilege" to a users definition of "privilege" and allow/deny access based on the combinations of definitions rather than a hard written code block for every single privlevel added to the db table. This way new privilege levels can be added into the database columns for the enum value(s) in the users/rooms table columns and their should be no additional coding required to restrict room access based on the new enum definitions.

Added privileged room
Added the ability for registered user - VIP/DONATOR/PRIVILEGED room.

Since the users privilege level does not have any type of tier concept to it, we can only compare the actual literal string value of the privilege level and check to see if a user is a part of the given privilege level to allow or deny them into a given room.

As explained when the privilege level concept was being introduced, we have admin level which is a bit comparison to allow the concept of admin > mod > reg > non-reg, but privilege level doesn't work like that. Its a sub category. So something like VIP !> DONATOR and vice versa.

With the logic in this PR a DONATOR for example can not enter a VIP room, nor can a VIP enter a DONATOR room, but we do compare admin level value(s) so regardless of admin/mod privilege levels they can enter the rooms. How ever an unregistered user is not allowed to enter the room if defined with the "vip" , "donator" or "privileged" database table privlevel"column value.

Clear as mud?

This PR adds a "privlevel" to the room so we can do easy comparisons between a rooms definition of "privilege" to a users definition of "privilege" and allow/deny access based on the combinations of definitions rather than a hard written code block for every single privlevel added to the db table. This way new privilege levels can be added into the database columns for the enum value(s) in the users/rooms table columns and their should be no additional coding required to restrict room access based on the new enum definitions.
@woogerboy21 woogerboy21 added App - Cockatrice Tickets relating to the cockatrice application App - Protocol / API Tickets that will require protocol level support in addition to client and server changes App - Servatrice Tickets relating to the servatrice application labels Mar 15, 2017
Copy link
Member

@ZeldaZach ZeldaZach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, but you never use the helper function you made

{
qDebug() << "USERPRIV: " << QString::fromStdString(userInfo.privlevel());

ServerInfo_Room roomInfo;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You create a roomInfo object, but never use it in the function, nor call getRoomPermissionDisplay()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You wouldn't call get..Display here, but this line doesn't need to be here, you're right

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops left what looks like a debug line in, I'll 🔪 it. As for the function, its called in the tab_server.cpp file to pull the room permissions to display in the table on the tab. 🍝

@@ -0,0 +1,6 @@
-- Servatrice db migration from version 22 to version 23

alter table cockatrice_rooms modify column permissionlevel enum('NONE','REGISTERED','MODERATOR','ADMINISTRATOR');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" over ' since the other line uses "? 🥇

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sql you use ' for strings; " is used to quote table and column names

Copy link
Contributor Author

@woogerboy21 woogerboy21 Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah they should be ' , not sure how one line came out one way and the other another. I will fix the line below it with " going "->'.

{
qDebug() << "USERPRIV: " << QString::fromStdString(userInfo.privlevel());

ServerInfo_Room roomInfo;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You wouldn't call get..Display here, but this line doesn't need to be here, you're right

@@ -0,0 +1,6 @@
-- Servatrice db migration from version 22 to version 23

alter table cockatrice_rooms modify column permissionlevel enum('NONE','REGISTERED','MODERATOR','ADMINISTRATOR');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sql you use ' for strings; " is used to quote table and column names

@woogerboy21
Copy link
Contributor Author

Should be all fixed up now. I'll see about throwing test box up for you guys to play with tomorrow. Heading to 🛏

bool Server_Room::userMayJoin(const ServerInfo_User & userInfo)
{

ServerInfo_Room roomInfo;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this is here if we never use it? Or do you use it implicitly and I didn't notice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swear I just answered this.... its used on line 624 of the protocol handler.
https://github.com/Cockatrice/Cockatrice/pull/2484/files#diff-d3b638a03e1222b79c2b7b5b8935096fR624

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that's a different function and this one isn't in scope there. Also it's a different type, this one is Server_Room and the other is ServerInfo_Room. I think you're mixed up here

Copy link
Contributor Author

@woogerboy21 woogerboy21 Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you mean the declaration of the roomInfo on line 42? If so yeah that might be a whoops / carry over from when I copied / pasted the code from the block that had it declared in before moving it into its own function. I thought you guys were referring to the actual function itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, line 42 :)

@woogerboy21
Copy link
Contributor Author

woogerboy21 commented Mar 17, 2017 via email

@ZeldaZach
Copy link
Member

I approved the code based on syntax and how it appears to function, i didn't get a chance to test it on a box. Will want to test before merging ofc

@woogerboy21
Copy link
Contributor Author

@ZeldaZach
I finally had time to stand up a box with this PR rolled in. People can test things out by using the host name of testing.woogerworks.com and port 4747 . You should be able to use the username/password you have on the main woogerworks server. I don't recall when the users table was pulled in on the testing server so if you recently changed your password the testing servers password might be your previous password.

@ZeldaZach
Copy link
Member

Tested and this seems to function as it should. :shipit:

* on the server tab needed to inform users of required permissions to enter a room. If the room has a privilege level
* the server tab will display the privilege level in the "permissions" column in the row however if the room contains
* a permissions level for the room the permissions level defined for the room will be displayed.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great comment

@ZeldaZach ZeldaZach merged commit 2f23a9c into Cockatrice:master Mar 23, 2017
@woogerboy21 woogerboy21 deleted the smarter_room branch July 24, 2017 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App - Cockatrice Tickets relating to the cockatrice application App - Protocol / API Tickets that will require protocol level support in addition to client and server changes App - Servatrice Tickets relating to the servatrice application
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants