mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-05 10:22:31 +01:00
* call toJSON of keys in gateway when using erlpack
* dont send bitrate/etc as null when should be undefined * set user flags to number instead of string * send empty 'threads' in identify when not using new state v2
This commit is contained in:
parent
a5a6321156
commit
a0d93fb252
@ -161,7 +161,7 @@ router.patch(
|
||||
const data = guild.toJSON();
|
||||
// TODO: guild hashes
|
||||
// TODO: fix vanity_url_code, template_id
|
||||
delete data.vanity_url_code;
|
||||
// delete data.vanity_url_code;
|
||||
delete data.template_id;
|
||||
|
||||
await Promise.all([
|
||||
|
@ -265,6 +265,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
return {
|
||||
...member.guild.toJSON(),
|
||||
joined_at: member.joined_at,
|
||||
|
||||
threads: [],
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -49,12 +49,12 @@ export interface ReadyPrivateChannel {
|
||||
|
||||
export type GuildOrUnavailable =
|
||||
| { id: string; unavailable: boolean }
|
||||
| (Guild & { joined_at?: Date; unavailable: boolean });
|
||||
| (Guild & { joined_at?: Date; unavailable: undefined });
|
||||
|
||||
const guildIsAvailable = (
|
||||
guild: GuildOrUnavailable,
|
||||
): guild is Guild & { joined_at: Date; unavailable: false } => {
|
||||
return guild.unavailable == false;
|
||||
return guild.unavailable != true;
|
||||
};
|
||||
|
||||
export interface IReadyGuildDTO {
|
||||
|
@ -468,6 +468,18 @@ export class Channel extends BaseClass {
|
||||
];
|
||||
return disallowedChannelTypes.indexOf(this.type) == -1;
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
...this,
|
||||
|
||||
// these fields are not returned depending on the type of channel
|
||||
bitrate: this.bitrate || undefined,
|
||||
user_limit: this.user_limit || undefined,
|
||||
rate_limit_per_user: this.rate_limit_per_user || undefined,
|
||||
owner_id: this.owner_id || undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export interface ChannelPermissionOverwrite {
|
||||
|
@ -390,4 +390,11 @@ export class Guild extends BaseClass {
|
||||
|
||||
return guild;
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
...this,
|
||||
unavailable: this.unavailable == false ? undefined : true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ export class User extends BaseClass {
|
||||
email?: string; // email of the user
|
||||
|
||||
@Column()
|
||||
flags: string = "0"; // UserFlags // TODO: generate
|
||||
flags: number = 0; // UserFlags // TODO: generate
|
||||
|
||||
@Column()
|
||||
public_flags: number = 0;
|
||||
|
@ -27,6 +27,16 @@ const JSONReplacer = function (
|
||||
return (this[key] as Date).toISOString().replace("Z", "+00:00");
|
||||
}
|
||||
|
||||
// erlpack encoding doesn't call json.stringify,
|
||||
// so our toJSON functions don't get called.
|
||||
// manually call it here
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
if (this?.[key]?.toJSON)
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
this[key] = this[key].toJSON();
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user