Skip to content

Commit

Permalink
Inv mods
Browse files Browse the repository at this point in the history
  • Loading branch information
madprops committed Feb 4, 2025
1 parent 35952ff commit dbba0d0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion server/sockets/modules/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ module.exports = (App) => {
return App.handler.get_out(socket)
}

if (!App.handler.user_is_invited(socket, info, userinfo)) {
if (!App.handler.user_is_invited(info, userinfo)) {
return App.handler.get_out(socket)
}

Expand Down
22 changes: 22 additions & 0 deletions server/sockets/modules/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ module.exports = (App) => {
}
}

// In limited mode ignore requests from non ops/admins
App.handler.check_limited = (socket) => {
let room = App.vars.rooms[socket.hue.room_id]

Expand All @@ -316,4 +317,25 @@ module.exports = (App) => {

return true
}

// Check if a user is at least voice in the room
App.handler.user_is_invited = (room, user) => {
if (room.public) {
return true
}

for (let user_id in room.keys) {
if (user_id === user.id) {
let role = room.keys[user_id]

if ([`admin`, `op`, `voice`].includes(role)) {
return true
}

break
}
}

return false
}
}
21 changes: 0 additions & 21 deletions server/sockets/modules/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,4 @@ module.exports = (App) => {
roomlist: App.roomlist,
})
}

// Check if a user is at least voice in the room
App.handler.user_is_invited = (socket, room, user) => {
if (room.public) {
return true
}

for (let user_id in room.keys) {
if (user_id === user.id) {
let role = room.keys[user_id]

if ([`admin`, `op`, `voice`].includes(role)) {
return true
}

break
}
}

return false
}
}

0 comments on commit dbba0d0

Please sign in to comment.