diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/entities/Member.ts | 20 | ||||
-rw-r--r-- | src/util/migrations/mariadb/1661785289467-guild-member-profiles.ts | 60 | ||||
-rw-r--r-- | src/util/migrations/postgres/1661785263936-guild-member-profiles.ts | 63 | ||||
-rw-r--r-- | src/util/migrations/sqlite/1661785235464-guild-member-profiles.ts | 136 | ||||
-rw-r--r-- | src/util/schemas/MemberChangeProfileSchema.ts | 5 | ||||
-rw-r--r-- | src/util/schemas/MemberChangeSchema.ts | 2 | ||||
-rw-r--r-- | src/util/schemas/UserProfileModifySchema.ts | 5 | ||||
-rw-r--r-- | src/util/schemas/index.ts | 2 |
8 files changed, 291 insertions, 2 deletions
diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts index 42a014d4..a2a7b8cb 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts @@ -94,7 +94,19 @@ export class Member extends BaseClassWithoutId { // do not auto-kick force-joined members just because their joiners left the server }) **/ @Column({ nullable: true }) - joined_by?: string; + joined_by: string; + + @Column({ nullable: true }) + avatar: string; + + @Column({ nullable: true }) + banner: string; + + @Column() + bio: string; + + @Column({ nullable: true }) + communication_disabled_until: Date; // TODO: add this when we have proper read receipts // @Column({ type: "simple-json" }) @@ -243,7 +255,11 @@ export class Member extends BaseClassWithoutId { premium_since: null, deaf: false, mute: false, - pending: false + pending: false, + avatar: null, + banner: null, + bio: "", + communication_disabled_until: null }; //TODO: check for bugs if (guild.member_count) guild.member_count++; diff --git a/src/util/migrations/mariadb/1661785289467-guild-member-profiles.ts b/src/util/migrations/mariadb/1661785289467-guild-member-profiles.ts new file mode 100644 index 00000000..223876f9 --- /dev/null +++ b/src/util/migrations/mariadb/1661785289467-guild-member-profiles.ts @@ -0,0 +1,60 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class guildMemberProfiles1661785289467 implements MigrationInterface { + name = 'guildMemberProfiles1661785289467' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE \`connected_accounts\` DROP COLUMN \`external_id\` + `); + await queryRunner.query(` + ALTER TABLE \`connected_accounts\` DROP COLUMN \`integrations\` + `); + await queryRunner.query(` + ALTER TABLE \`members\` + ADD \`avatar\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`members\` + ADD \`banner\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`members\` + ADD \`bio\` varchar(255) NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`members\` + ADD \`communication_disabled_until\` datetime NULL + `); + await queryRunner.query(` + ALTER TABLE \`connected_accounts\` CHANGE \`access_token\` \`access_token\` varchar(255) NOT NULL + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE \`connected_accounts\` CHANGE \`access_token\` \`access_token\` varchar(255) NULL + `); + await queryRunner.query(` + ALTER TABLE \`members\` DROP COLUMN \`communication_disabled_until\` + `); + await queryRunner.query(` + ALTER TABLE \`members\` DROP COLUMN \`bio\` + `); + await queryRunner.query(` + ALTER TABLE \`members\` DROP COLUMN \`banner\` + `); + await queryRunner.query(` + ALTER TABLE \`members\` DROP COLUMN \`avatar\` + `); + await queryRunner.query(` + ALTER TABLE \`connected_accounts\` + ADD \`integrations\` text NOT NULL + `); + await queryRunner.query(` + ALTER TABLE \`connected_accounts\` + ADD \`external_id\` varchar(255) NOT NULL + `); + } + +} diff --git a/src/util/migrations/postgres/1661785263936-guild-member-profiles.ts b/src/util/migrations/postgres/1661785263936-guild-member-profiles.ts new file mode 100644 index 00000000..af0f2a33 --- /dev/null +++ b/src/util/migrations/postgres/1661785263936-guild-member-profiles.ts @@ -0,0 +1,63 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class guildMemberProfiles1661785263936 implements MigrationInterface { + name = 'guildMemberProfiles1661785263936' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "connected_accounts" DROP COLUMN "external_id" + `); + await queryRunner.query(` + ALTER TABLE "connected_accounts" DROP COLUMN "integrations" + `); + await queryRunner.query(` + ALTER TABLE "members" + ADD "avatar" character varying + `); + await queryRunner.query(` + ALTER TABLE "members" + ADD "banner" character varying + `); + await queryRunner.query(` + ALTER TABLE "members" + ADD "bio" character varying NOT NULL + `); + await queryRunner.query(` + ALTER TABLE "members" + ADD "communication_disabled_until" TIMESTAMP + `); + await queryRunner.query(` + ALTER TABLE "connected_accounts" + ALTER COLUMN "access_token" + SET NOT NULL + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + ALTER TABLE "connected_accounts" + ALTER COLUMN "access_token" DROP NOT NULL + `); + await queryRunner.query(` + ALTER TABLE "members" DROP COLUMN "communication_disabled_until" + `); + await queryRunner.query(` + ALTER TABLE "members" DROP COLUMN "bio" + `); + await queryRunner.query(` + ALTER TABLE "members" DROP COLUMN "banner" + `); + await queryRunner.query(` + ALTER TABLE "members" DROP COLUMN "avatar" + `); + await queryRunner.query(` + ALTER TABLE "connected_accounts" + ADD "integrations" text NOT NULL + `); + await queryRunner.query(` + ALTER TABLE "connected_accounts" + ADD "external_id" character varying NOT NULL + `); + } + +} diff --git a/src/util/migrations/sqlite/1661785235464-guild-member-profiles.ts b/src/util/migrations/sqlite/1661785235464-guild-member-profiles.ts new file mode 100644 index 00000000..9a3b648d --- /dev/null +++ b/src/util/migrations/sqlite/1661785235464-guild-member-profiles.ts @@ -0,0 +1,136 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class guildMemberProfiles1661785235464 implements MigrationInterface { + name = 'guildMemberProfiles1661785235464' + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + DROP INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" + `); + await queryRunner.query(` + CREATE TABLE "temporary_members" ( + "index" integer PRIMARY KEY AUTOINCREMENT NOT NULL, + "id" varchar NOT NULL, + "guild_id" varchar NOT NULL, + "nick" varchar, + "joined_at" datetime NOT NULL, + "premium_since" datetime, + "deaf" boolean NOT NULL, + "mute" boolean NOT NULL, + "pending" boolean NOT NULL, + "settings" text NOT NULL, + "last_message_id" varchar, + "joined_by" varchar, + "avatar" varchar, + "banner" varchar, + "bio" varchar NOT NULL, + "communication_disabled_until" datetime, + CONSTRAINT "FK_28b53062261b996d9c99fa12404" FOREIGN KEY ("id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_16aceddd5b89825b8ed6029ad1c" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "temporary_members"( + "index", + "id", + "guild_id", + "nick", + "joined_at", + "premium_since", + "deaf", + "mute", + "pending", + "settings", + "last_message_id", + "joined_by" + ) + SELECT "index", + "id", + "guild_id", + "nick", + "joined_at", + "premium_since", + "deaf", + "mute", + "pending", + "settings", + "last_message_id", + "joined_by" + FROM "members" + `); + await queryRunner.query(` + DROP TABLE "members" + `); + await queryRunner.query(` + ALTER TABLE "temporary_members" + RENAME TO "members" + `); + await queryRunner.query(` + CREATE UNIQUE INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" ON "members" ("id", "guild_id") + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(` + DROP INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" + `); + await queryRunner.query(` + ALTER TABLE "members" + RENAME TO "temporary_members" + `); + await queryRunner.query(` + CREATE TABLE "members" ( + "index" integer PRIMARY KEY AUTOINCREMENT NOT NULL, + "id" varchar NOT NULL, + "guild_id" varchar NOT NULL, + "nick" varchar, + "joined_at" datetime NOT NULL, + "premium_since" datetime, + "deaf" boolean NOT NULL, + "mute" boolean NOT NULL, + "pending" boolean NOT NULL, + "settings" text NOT NULL, + "last_message_id" varchar, + "joined_by" varchar, + CONSTRAINT "FK_28b53062261b996d9c99fa12404" FOREIGN KEY ("id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, + CONSTRAINT "FK_16aceddd5b89825b8ed6029ad1c" FOREIGN KEY ("guild_id") REFERENCES "guilds" ("id") ON DELETE CASCADE ON UPDATE NO ACTION + ) + `); + await queryRunner.query(` + INSERT INTO "members"( + "index", + "id", + "guild_id", + "nick", + "joined_at", + "premium_since", + "deaf", + "mute", + "pending", + "settings", + "last_message_id", + "joined_by" + ) + SELECT "index", + "id", + "guild_id", + "nick", + "joined_at", + "premium_since", + "deaf", + "mute", + "pending", + "settings", + "last_message_id", + "joined_by" + FROM "temporary_members" + `); + await queryRunner.query(` + DROP TABLE "temporary_members" + `); + await queryRunner.query(` + CREATE UNIQUE INDEX "IDX_bb2bf9386ac443afbbbf9f12d3" ON "members" ("id", "guild_id") + `); + } + +} diff --git a/src/util/schemas/MemberChangeProfileSchema.ts b/src/util/schemas/MemberChangeProfileSchema.ts new file mode 100644 index 00000000..3e85174d --- /dev/null +++ b/src/util/schemas/MemberChangeProfileSchema.ts @@ -0,0 +1,5 @@ +export interface MemberChangeProfileSchema { + banner?: string | null; + nick?: string; + bio?: string; +} diff --git a/src/util/schemas/MemberChangeSchema.ts b/src/util/schemas/MemberChangeSchema.ts index db434538..0cbab4a3 100644 --- a/src/util/schemas/MemberChangeSchema.ts +++ b/src/util/schemas/MemberChangeSchema.ts @@ -1,3 +1,5 @@ export interface MemberChangeSchema { roles?: string[]; + nick?: string; + avatar?: string | null; } diff --git a/src/util/schemas/UserProfileModifySchema.ts b/src/util/schemas/UserProfileModifySchema.ts new file mode 100644 index 00000000..33a372c9 --- /dev/null +++ b/src/util/schemas/UserProfileModifySchema.ts @@ -0,0 +1,5 @@ +export interface UserProfileModifySchema { + bio?: string; + accent_color?: number | null; + banner?: string | null; +} diff --git a/src/util/schemas/index.ts b/src/util/schemas/index.ts index a15ab4b0..3770daf0 100644 --- a/src/util/schemas/index.ts +++ b/src/util/schemas/index.ts @@ -17,6 +17,7 @@ export * from "./IdentifySchema"; export * from "./InviteCreateSchema"; export * from "./LazyRequestSchema"; export * from "./LoginSchema"; +export * from "./MemberChangeProfileSchema"; export * from "./MemberChangeSchema"; export * from "./MemberNickChangeSchema"; export * from "./MessageAcknowledgeSchema"; @@ -36,6 +37,7 @@ export * from "./TotpDisableSchema"; export * from "./TotpEnableSchema"; export * from "./TotpSchema"; export * from "./UserModifySchema"; +export * from "./UserProfileModifySchema"; export * from "./UserSettingsSchema"; export * from "./VanityUrlSchema"; export * from "./VoiceStateUpdateSchema"; |