diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/entities/Member.ts | 20 | ||||
-rw-r--r-- | src/util/migrations/mariadb/1661885910534-guild-member-profiles.ts | 40 | ||||
-rw-r--r-- | src/util/migrations/postgres/1661885830688-guild-member-profiles.ts | 40 | ||||
-rw-r--r-- | src/util/migrations/sqlite/1661885742207-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, 248 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/1661885910534-guild-member-profiles.ts b/src/util/migrations/mariadb/1661885910534-guild-member-profiles.ts new file mode 100644 index 00000000..6e1ac3f8 --- /dev/null +++ b/src/util/migrations/mariadb/1661885910534-guild-member-profiles.ts @@ -0,0 +1,40 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class guildMemberProfiles1661885910534 implements MigrationInterface { + name = 'guildMemberProfiles1661885910534' + + public async up(queryRunner: QueryRunner): Promise<void> { + 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 + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + 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\` + `); + } + +} diff --git a/src/util/migrations/postgres/1661885830688-guild-member-profiles.ts b/src/util/migrations/postgres/1661885830688-guild-member-profiles.ts new file mode 100644 index 00000000..b774743b --- /dev/null +++ b/src/util/migrations/postgres/1661885830688-guild-member-profiles.ts @@ -0,0 +1,40 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class guildMemberProfiles1661885830688 implements MigrationInterface { + name = 'guildMemberProfiles1661885830688' + + public async up(queryRunner: QueryRunner): Promise<void> { + 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 + `); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + 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" + `); + } + +} diff --git a/src/util/migrations/sqlite/1661885742207-guild-member-profiles.ts b/src/util/migrations/sqlite/1661885742207-guild-member-profiles.ts new file mode 100644 index 00000000..24ec9c72 --- /dev/null +++ b/src/util/migrations/sqlite/1661885742207-guild-member-profiles.ts @@ -0,0 +1,136 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class guildMemberProfiles1661885742207 implements MigrationInterface { + name = 'guildMemberProfiles1661885742207' + + 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"; |