Commit 89b923b1 authored by vehjelmtvedt's avatar vehjelmtvedt
Browse files

add getRole and hasPermission methods

parent 46eb1063
......@@ -530,6 +530,18 @@ public class Handler extends AbstractHandler
});
}
private boolean hasPermission(Role role, String request) {
// Permissions for a newmessage request
if (request.equals("newmessage")) {
return !role.equals(Role.BANNED);
// Permissions for an editmessage or deletemessage request
} else if (request.equals("editmessage") || request.equals("deletemessage")) {
// Owner and mod can edit anything
return role.equals(Role.OWNER) || role.equals(Role.MODERATOR);
}
return false;
}
/**
* Load all the cookies into a map for easy retrieval.
*/
......
......@@ -249,6 +249,10 @@ public class InChat {
});
}
public Maybe<Role> getRole(Stored<Account> account, Stored<Channel> channel) {
return Util.lookupTriple(account.value.channels, channel.value.name);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment