yariplus / minecraft-nodebb-integration

A plugin for Minecraft servers for integration with a NodeBB forum.
Creative Commons Zero v1.0 Universal
9 stars 4 forks source link

Forum group/rank syncing #19

Open da-van opened 8 years ago

da-van commented 8 years ago

How does this work from server to forum and vice versa? What group/rank systems are supported? Any chance on getting support for PexPermissions ranks? :)

Apart from this, absolutely stellar plugin! Amazed at how well it works. Top job!

yariplus commented 8 years ago

Thanks!

Right now there is no real rank syncing. Whenever a player signs onto the server, I grab their rank prefixes from the server and pipe them to the forum templates. So, their forum username appears as {rank1prefix} {rank2prefix} {playerprefix} {username}

What it should eventually do is create and add them to a linked group on the forum (where the identifier is the rank name and the display name is the rank prefix). This would be synced both ways, so an admin could also add a linked forum user to a server rank by adding them to the linked forum group, and remove their rank by removing them from the linked group. Only the server plugin would be able to create and manage linked groups, so there would be no chance of players getting a rank by creating a user group. furthermore, if a forum user unlinks their forum account, they would be removed from all linked forum groups.

yariplus commented 8 years ago

For your other question, this should support every permission plugin out there. If you have one that doesn't work, I will add it in support for it.

yariplus commented 8 years ago

Going to make finishing this the top priority for the next release.

da-van commented 8 years ago

Awesome :) I was going to take a look at it as well. I'll let you know if I get anywhere

da-van commented 8 years ago

I've been looking into this but I've hit a pretty big wall. I can't for the life of me figure out how to grab someone's group membership list with MongoDB queries. Any ideas?

yariplus commented 8 years ago

Are you trying to get them from the forum side or server side?

You can commit what you have so far, might be easier if I see the actual code.

da-van commented 8 years ago

I've written little code yet. Before getting into it, I was attempting to find where the groups a user is a part of is located in the database. Using MongoDB queries directly in the mongo shell.

On 16 May 2016, at 23:13, Timothy Fike notifications@github.com wrote:

Are you trying to get them from the forum side or server side?

You can commit what you have so far, might be easier if I see the actual code.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub

yariplus commented 8 years ago

Ohhh, okay.

I'm not really sure the best way using mongo queries. In the forum you would just do Groups.getUserGroups(uid, callback).

If you want to test using queries, This should help you get started

userGroups = []
db.objects.find({_key: 'groups:createtime', value: {$regex: /^[^:]*$/}}, {value: true}).forEach(function(group){ if (!!db.objects.find({_key: 'group:'+group.value+':members', value: '1'})) userGroups.push(group.value) })
print(userGroups)
da-van commented 8 years ago

Hey, so your query works great to grab the list of groups that exist, that's no problem. I can see entries for how many members are in each group. Also no issue to get a list of all the users.

The problem is, using queries (or code if you prefer), finding out exactly which groups a particular member is a part of, or finding out a full list of members that are in a specific group.

E.g. db.objects.find({_key:'user:1'}) will return a lot of information about user 1 but makes no mention of their membership to any groups in NodeBB.

If we were to query the user's yuuid value (which I see you've add to users reigstered with Minecraft Integration) and find the user the uuid belongs to, how are we to determine whether that NodeBB user belongs to the Administrator group or the Registered Member group?

Any ideas? :)

Sorry, seems I overlooked the first code snippet you posted. That returns a list of groups a uid belongs to? What would be the mongo query to do the same thing?

yariplus commented 8 years ago

Groups.getUserGroups does two queries. In mongo, try it like this.

uid = "1"; allGroups = db.objects.find({_key: 'groups:createtime', value: {$regex: /^[^:]*$/}}); userGroups = []; allGroups.forEach(function(group){ if (!!db.objects.find({_key: 'group:'+group.value+':members', value: uid}).length()) userGroups.push(group.value); }); print(userGroups);
da-van commented 8 years ago

Awesome! That does the trick. I have much to learn about MongoDB. :)

yariplus commented 8 years ago

Let me know if you have any code to contribute. Going to start working on this for the next few weeks.