Merge branch 'master' into feat/refactorIdentify
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
|
||||
import { ConnectedAccountTokenData } from "../interfaces";
|
||||
import { BaseClass } from "./BaseClass";
|
||||
import { User } from "./User";
|
||||
|
||||
@@ -27,6 +28,9 @@ export type PublicConnectedAccount = Pick<
|
||||
|
||||
@Entity("connected_accounts")
|
||||
export class ConnectedAccount extends BaseClass {
|
||||
@Column()
|
||||
external_id: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
@RelationId((account: ConnectedAccount) => account.user)
|
||||
user_id: string;
|
||||
@@ -38,26 +42,44 @@ export class ConnectedAccount extends BaseClass {
|
||||
user: User;
|
||||
|
||||
@Column({ select: false })
|
||||
access_token: string;
|
||||
|
||||
@Column({ select: false })
|
||||
friend_sync: boolean;
|
||||
friend_sync?: boolean = false;
|
||||
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
@Column({ select: false })
|
||||
revoked: boolean;
|
||||
revoked?: boolean = false;
|
||||
|
||||
@Column({ select: false })
|
||||
show_activity: boolean;
|
||||
show_activity?: number = 0;
|
||||
|
||||
@Column()
|
||||
type: string;
|
||||
|
||||
@Column()
|
||||
verified: boolean;
|
||||
verified?: boolean = true;
|
||||
|
||||
@Column({ select: false })
|
||||
visibility: number;
|
||||
visibility?: number = 0;
|
||||
|
||||
@Column({ type: "simple-array" })
|
||||
integrations?: string[] = [];
|
||||
|
||||
@Column({ type: "simple-json", name: "metadata", nullable: true })
|
||||
metadata_?: any;
|
||||
|
||||
@Column()
|
||||
metadata_visibility?: number = 0;
|
||||
|
||||
@Column()
|
||||
two_way_link?: boolean = false;
|
||||
|
||||
@Column({ select: false, nullable: true, type: "simple-json" })
|
||||
token_data?: ConnectedAccountTokenData | null;
|
||||
|
||||
async revoke() {
|
||||
this.revoked = true;
|
||||
this.token_data = null;
|
||||
await this.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Spacebar: A FOSS re-implementation and extension of the Discord.com backend.
|
||||
Copyright (C) 2023 Spacebar and Spacebar Contributors
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Column, Entity } from "typeorm";
|
||||
import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass";
|
||||
|
||||
@Entity("connection_config")
|
||||
export class ConnectionConfigEntity extends BaseClassWithoutId {
|
||||
@PrimaryIdColumn()
|
||||
key: string;
|
||||
|
||||
@Column({ type: "simple-json", nullable: true })
|
||||
value: number | boolean | null | string | Date | undefined;
|
||||
}
|
||||
+28
-11
@@ -260,9 +260,9 @@ export class Member extends BaseClassWithoutId {
|
||||
},
|
||||
},
|
||||
}),
|
||||
await Role.findOneOrFail({ where: { id: role_id, guild_id } }),
|
||||
Role.findOneOrFail({ where: { id: role_id, guild_id } }),
|
||||
]);
|
||||
member.roles = member.roles.filter((x) => x.id == role_id);
|
||||
member.roles = member.roles.filter((x) => x.id !== role_id);
|
||||
|
||||
await Promise.all([
|
||||
member.save(),
|
||||
@@ -330,17 +330,25 @@ export class Member extends BaseClassWithoutId {
|
||||
});
|
||||
|
||||
const memberCount = await Member.count({ where: { guild_id } });
|
||||
const memberPreview = await Member.find({
|
||||
where: {
|
||||
guild_id,
|
||||
user: {
|
||||
sessions: {
|
||||
status: Not("invisible" as const), // lol typescript?
|
||||
|
||||
const memberPreview = (
|
||||
await Member.find({
|
||||
where: {
|
||||
guild_id,
|
||||
user: {
|
||||
sessions: {
|
||||
status: Not("invisible" as const), // lol typescript?
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
take: 10,
|
||||
});
|
||||
relations: ["user", "roles"],
|
||||
take: 10,
|
||||
})
|
||||
).map((member) => ({
|
||||
...member.toPublicMember(),
|
||||
user: member.user.toPublicUser(),
|
||||
roles: member.roles.map((x) => x.id),
|
||||
}));
|
||||
|
||||
if (
|
||||
await Member.count({
|
||||
@@ -440,6 +448,15 @@ export class Member extends BaseClassWithoutId {
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
toPublicMember() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const member: any = {};
|
||||
PublicMemberProjection.forEach((x) => {
|
||||
member[x] = this[x];
|
||||
});
|
||||
return member as PublicMember;
|
||||
}
|
||||
}
|
||||
|
||||
export interface ChannelOverride {
|
||||
|
||||
@@ -27,6 +27,7 @@ export * from "./Channel";
|
||||
export * from "./ClientRelease";
|
||||
export * from "./Config";
|
||||
export * from "./ConnectedAccount";
|
||||
export * from "./ConnectionConfigEntity";
|
||||
export * from "./EmbedCache";
|
||||
export * from "./Emoji";
|
||||
export * from "./Encryption";
|
||||
|
||||
Reference in New Issue
Block a user