Add Twitch, error handling, revokation changes, etc

This commit is contained in:
Puyodead1
2023-03-18 19:28:45 -04:00
parent a60f147156
commit 6d6944cfee
19 changed files with 416 additions and 46 deletions
@@ -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;
}
+1 -1
View File
@@ -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;
+8 -2
View File
@@ -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();
}
}
+1
View File
@@ -13,4 +13,5 @@ export interface ConnectedAccountTokenData {
refresh_token?: string;
expires_in?: number;
expires_at?: number;
fetched_at: number;
}
+1 -1
View File
@@ -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;
}
+5
View File
@@ -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,