mirror of
https://github.com/spacebarchat/server.git
synced 2026-07-28 18:29:26 +00:00
Add Twitch, error handling, revokation changes, etc
This commit is contained in:
@@ -23,7 +23,7 @@ export default abstract class RefreshableConnection extends Connection {
|
||||
connectedAccount: ConnectedAccount,
|
||||
): Promise<ConnectedAccountCommonOAuthTokenResponse> {
|
||||
const tokenData = await this.refreshToken(connectedAccount);
|
||||
connectedAccount.token_data = tokenData;
|
||||
connectedAccount.token_data = { ...tokenData, fetched_at: Date.now() };
|
||||
await connectedAccount.save();
|
||||
return tokenData;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export class ConnectedAccountDTO {
|
||||
friend_sync?: boolean;
|
||||
name: string;
|
||||
revoked?: boolean;
|
||||
show_activity?: boolean;
|
||||
show_activity?: number;
|
||||
type: string;
|
||||
verified?: boolean;
|
||||
visibility?: number;
|
||||
|
||||
@@ -51,7 +51,7 @@ export class ConnectedAccount extends BaseClass {
|
||||
revoked?: boolean = false;
|
||||
|
||||
@Column({ select: false })
|
||||
show_activity?: boolean = true;
|
||||
show_activity?: number = 0;
|
||||
|
||||
@Column()
|
||||
type: string;
|
||||
@@ -75,5 +75,11 @@ export class ConnectedAccount extends BaseClass {
|
||||
two_way_link?: boolean = false;
|
||||
|
||||
@Column({ select: false, nullable: true, type: "simple-json" })
|
||||
token_data?: ConnectedAccountTokenData;
|
||||
token_data?: ConnectedAccountTokenData | null;
|
||||
|
||||
async revoke() {
|
||||
this.revoked = true;
|
||||
this.token_data = null;
|
||||
await this.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,5 @@ export interface ConnectedAccountTokenData {
|
||||
refresh_token?: string;
|
||||
expires_in?: number;
|
||||
expires_at?: number;
|
||||
fetched_at: number;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export interface ConnectedAccountSchema {
|
||||
friend_sync?: boolean;
|
||||
name: string;
|
||||
revoked?: boolean;
|
||||
show_activity?: boolean;
|
||||
show_activity?: number;
|
||||
type: string;
|
||||
verified?: boolean;
|
||||
visibility?: number;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export interface ConnectionUpdateSchema {
|
||||
visibility?: boolean;
|
||||
show_activity?: boolean;
|
||||
}
|
||||
|
||||
@@ -787,6 +787,11 @@ export const DiscordApiErrors = {
|
||||
40006,
|
||||
),
|
||||
USER_BANNED: new ApiError("The user is banned from this guild", 40007),
|
||||
CONNECTION_REVOKED: new ApiError(
|
||||
"The connection has been revoked",
|
||||
40012,
|
||||
400,
|
||||
),
|
||||
TARGET_USER_IS_NOT_CONNECTED_TO_VOICE: new ApiError(
|
||||
"Target user is not connected to voice",
|
||||
40032,
|
||||
|
||||
Reference in New Issue
Block a user