move permission stuff to the resolver (#1185)

This commit is contained in:
Gus Caplan
2017-02-22 14:11:11 -06:00
committed by Amish Shah
parent f01b3f922d
commit 566135d25b
2 changed files with 17 additions and 9 deletions

View File

@@ -217,6 +217,20 @@ class ClientDataResolver {
return bitfield;
}
hasPermission(bitfield, name, explicit = false) {
const permission = this.resolvePermission(name);
if (!explicit && (bitfield & Constants.PermissionFlags.ADMINISTRATOR) > 0) return true;
return (bitfield & permission) > 0;
}
serializePermissions(bitfield) {
const serializedPermissions = {};
for (const name in Constants.PermissionFlags) {
serializedPermissions[name] = this.hasPermission(bitfield, name);
}
return serializedPermissions;
}
/**
* Data that can be resolved to give a string. This can be:
* * A string