mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-21 04:25:27 -04:00
feat: privileged field on user
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "revolt.js",
|
||||
"version": "6.0.0-rc.24",
|
||||
"version": "6.0.0-rc.25",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"module": "esm/index.js",
|
||||
@@ -17,7 +17,7 @@
|
||||
"lodash.isequal": "^4.5.0",
|
||||
"long": "^5.2.0",
|
||||
"mobx": "^6.3.2",
|
||||
"revolt-api": "0.5.3-rc.15",
|
||||
"revolt-api": "0.5.3-rc.16",
|
||||
"ulid": "^2.3.0",
|
||||
"ws": "^8.2.2"
|
||||
},
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
export const LIBRARY_VERSION = "6.0.0-rc.13";
|
||||
export const LIBRARY_VERSION = "6.0.0-rc.25";
|
||||
|
||||
export const defaultConfig = {
|
||||
apiURL: "https://api.revolt.chat",
|
||||
|
||||
+5
-2
@@ -28,7 +28,8 @@ export class User {
|
||||
badges: Nullable<number>;
|
||||
status: Nullable<UserStatus>;
|
||||
relationship: Nullable<RelationshipStatus>;
|
||||
online: Nullable<boolean>;
|
||||
online: boolean;
|
||||
privileged: boolean;
|
||||
flags: Nullable<number>;
|
||||
bot: Nullable<BotInformation>;
|
||||
|
||||
@@ -49,7 +50,8 @@ export class User {
|
||||
this.badges = toNullable(data.badges);
|
||||
this.status = toNullable(data.status);
|
||||
this.relationship = toNullable(data.relationship);
|
||||
this.online = toNullable(data.online);
|
||||
this.online = data.online ?? false;
|
||||
this.privileged = data.privileged ?? false;
|
||||
this.flags = toNullable(data.flags);
|
||||
this.bot = toNullable(data.bot);
|
||||
|
||||
@@ -96,6 +98,7 @@ export class User {
|
||||
apply("status");
|
||||
apply("relationship");
|
||||
apply("online");
|
||||
apply("privileged");
|
||||
apply("flags");
|
||||
apply("bot");
|
||||
}
|
||||
|
||||
@@ -31,15 +31,20 @@ export function calculatePermission(
|
||||
member?: Member;
|
||||
},
|
||||
): number {
|
||||
const user = options?.member ? options?.member.user : target.client.user;
|
||||
if (user?.privileged) {
|
||||
return Permission.GrantAllSafe;
|
||||
}
|
||||
|
||||
if (target instanceof Server) {
|
||||
// 1. Check if owner.
|
||||
if (target.owner === target.client.user?._id) {
|
||||
if (target.owner === user?._id) {
|
||||
return Permission.GrantAllSafe;
|
||||
} else {
|
||||
// 2. Get member.
|
||||
const member = options?.member ??
|
||||
target.client.members.getKey({
|
||||
user: target.client.user!._id,
|
||||
user: user!._id,
|
||||
server: target._id,
|
||||
}) ?? { roles: null };
|
||||
|
||||
@@ -82,7 +87,7 @@ export function calculatePermission(
|
||||
}
|
||||
case "Group": {
|
||||
// 2. Check if user is owner.
|
||||
if (target.owner_id === target.client.user!._id) {
|
||||
if (target.owner_id === user!._id) {
|
||||
return DEFAULT_PERMISSION_DIRECT_MESSAGE;
|
||||
} else {
|
||||
// 3. Pull out group permissions.
|
||||
@@ -98,13 +103,13 @@ export function calculatePermission(
|
||||
if (typeof server === "undefined") return 0;
|
||||
|
||||
// 3. If server owner, just grant all permissions.
|
||||
if (server.owner === target.client.user?._id) {
|
||||
if (server.owner === user?._id) {
|
||||
return Permission.GrantAllSafe;
|
||||
} else {
|
||||
// 4. Get member.
|
||||
const member = options?.member ??
|
||||
target.client.members.getKey({
|
||||
user: target.client.user!._id,
|
||||
user: user!._id,
|
||||
server: server._id,
|
||||
}) ?? { roles: null };
|
||||
|
||||
|
||||
@@ -1018,10 +1018,10 @@ reusify@^1.0.4:
|
||||
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
|
||||
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==
|
||||
|
||||
revolt-api@0.5.3-rc.15:
|
||||
version "0.5.3-rc.15"
|
||||
resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.3-rc.15.tgz#abd08dd8109d0ca31be118461eabbeb6c3b7792e"
|
||||
integrity sha512-MYin3U+KoObNkILPf2cz+FPperynExkUu7CjzurMJCRvBncpnhb2czvWDvnhLDKBHlpo8W597xNqzQnaklV4ug==
|
||||
revolt-api@0.5.3-rc.16:
|
||||
version "0.5.3-rc.16"
|
||||
resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.3-rc.16.tgz#7c6ecab99286fd54e8b19a878afafda0bea9e6f3"
|
||||
integrity sha512-KMTMMaJxf9MsWFHjkcL0/I+5gaa4NDnR0yTC6BZ3eObTxLmAHUAD8OsCB/aewGR7zKDSyuNWBVXHDpLjb+6JrA==
|
||||
dependencies:
|
||||
"@insertish/oapi" "0.1.15"
|
||||
axios "^0.26.1"
|
||||
|
||||
Reference in New Issue
Block a user