From 40f08ed76c35daea8a1e743d2076e27ea4d7e40f Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Thu, 31 Mar 2022 01:21:40 +1100 Subject: Fix typo in table 'client_relase' -> 'client_release' ( and other of the same typo ) (#703) * Fixed typo in table name 'client_relase' -> 'client_release'. Fixed more typos of the same typo. * Fixed migration ( but dirty lol ) --- util/src/entities/ClientRelase.ts | 26 ------------------------ util/src/entities/ClientRelease.ts | 26 ++++++++++++++++++++++++ util/src/entities/Config.ts | 10 ++++----- util/src/entities/index.ts | 2 +- util/src/migrations/1648643945733-ReleaseTypo.ts | 16 +++++++++++++++ 5 files changed, 48 insertions(+), 32 deletions(-) delete mode 100644 util/src/entities/ClientRelase.ts create mode 100644 util/src/entities/ClientRelease.ts create mode 100644 util/src/migrations/1648643945733-ReleaseTypo.ts (limited to 'util/src') diff --git a/util/src/entities/ClientRelase.ts b/util/src/entities/ClientRelase.ts deleted file mode 100644 index e021b82b..00000000 --- a/util/src/entities/ClientRelase.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Column, Entity} from "typeorm"; -import { BaseClass } from "./BaseClass"; - -@Entity("client_relase") -export class Relase extends BaseClass { - @Column() - name: string; - - @Column() - pub_date: string; - - @Column() - url: string; - - @Column() - deb_url: string; - - @Column() - osx_url: string; - - @Column() - win_url: string; - - @Column({ nullable: true }) - notes?: string; -} diff --git a/util/src/entities/ClientRelease.ts b/util/src/entities/ClientRelease.ts new file mode 100644 index 00000000..c5afd307 --- /dev/null +++ b/util/src/entities/ClientRelease.ts @@ -0,0 +1,26 @@ +import { Column, Entity} from "typeorm"; +import { BaseClass } from "./BaseClass"; + +@Entity("client_release") +export class Release extends BaseClass { + @Column() + name: string; + + @Column() + pub_date: string; + + @Column() + url: string; + + @Column() + deb_url: string; + + @Column() + osx_url: string; + + @Column() + win_url: string; + + @Column({ nullable: true }) + notes?: string; +} diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts index f4a266dc..8d29b387 100644 --- a/util/src/entities/Config.ts +++ b/util/src/entities/Config.ts @@ -188,8 +188,8 @@ export interface ConfigValue { }, client: { useTestClient: Boolean; - relases: { - useLocalRelases: Boolean; //TODO + releases: { + useLocalRelease: Boolean; //TODO upstreamVersion: string; } }, @@ -222,7 +222,7 @@ export const DefaultConfigOptions: ConfigValue = { }, general: { instanceName: "Fosscord Instance", - instanceDescription: "This is a Fosscord instance made in pre-relase days", + instanceDescription: "This is a Fosscord instance made in pre-release days", frontPage: null, tosPage: null, correspondenceEmail: "noreply@localhost.local", @@ -389,8 +389,8 @@ export const DefaultConfigOptions: ConfigValue = { }, client: { useTestClient: true, - relases: { - useLocalRelases: true, + releases: { + useLocalRelease: true, upstreamVersion: "0.0.264" } }, diff --git a/util/src/entities/index.ts b/util/src/entities/index.ts index fc18d422..f023d5a6 100644 --- a/util/src/entities/index.ts +++ b/util/src/entities/index.ts @@ -27,4 +27,4 @@ export * from "./Template"; export * from "./User"; export * from "./VoiceState"; export * from "./Webhook"; -export * from "./ClientRelase"; \ No newline at end of file +export * from "./ClientRelease"; \ No newline at end of file diff --git a/util/src/migrations/1648643945733-ReleaseTypo.ts b/util/src/migrations/1648643945733-ReleaseTypo.ts new file mode 100644 index 00000000..944b9dd9 --- /dev/null +++ b/util/src/migrations/1648643945733-ReleaseTypo.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class ReleaseTypo1648643945733 implements MigrationInterface { + name = "ReleaseTypo1648643945733"; + + public async up(queryRunner: QueryRunner): Promise { + //drop table first because typeorm creates it before migrations run + await queryRunner.dropTable("client_release", true); + await queryRunner.renameTable("client_relase", "client_release"); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropTable("client_relase", true); + await queryRunner.renameTable("client_release", "client_relase"); + } +} -- cgit 1.5.1 From 31bfe2a22a81b0878e9232d91b19925ff12d4007 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sat, 2 Apr 2022 10:22:54 +0300 Subject: first steps for E2EE support — channel security settings event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/src/entities/Encryption.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 util/src/entities/Encryption.ts (limited to 'util/src') diff --git a/util/src/entities/Encryption.ts b/util/src/entities/Encryption.ts new file mode 100644 index 00000000..3b82ff84 --- /dev/null +++ b/util/src/entities/Encryption.ts @@ -0,0 +1,35 @@ +import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm"; +import { BaseClass } from "./BaseClass"; +import { Guild } from "./Guild"; +import { PublicUserProjection, User } from "./User"; +import { HTTPError } from "lambert-server"; +import { containsAll, emitEvent, getPermission, Snowflake, trimSpecial, InvisibleCharacters } from "../util"; +import { BitField, BitFieldResolvable, BitFlag } from "../util/BitField"; +import { Recipient } from "./Recipient"; +import { Message } from "./Message"; +import { ReadState } from "./ReadState"; +import { Invite } from "./Invite"; +import { DmChannelDTO } from "../dtos"; + +@Entity("security_settings") +export class SecuritySettings extends BaseClass { + + @Column({nullable: true}) + guild_id: Snowflake; + + @Column({nullable: true}) + channel_id: Snowflake; + + @Column() + encryption_permission_mask: BitField; + + @Column() + allowed_algorithms: string[]; + + @Column() + current_algorithm: string; + + @Column({nullable: true}) + used_since_message: Snowflake; + +} -- cgit 1.5.1 From 18aa4c405bab0ebf2c7dd1fd1d7e33475f764c6a Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sat, 2 Apr 2022 12:06:14 +0300 Subject: More message types --- util/src/entities/Message.ts | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'util/src') diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts index e577d5df..04b04747 100644 --- a/util/src/entities/Message.ts +++ b/util/src/entities/Message.ts @@ -41,8 +41,14 @@ export enum MessageType { CHANNEL_FOLLOW_ADD = 12, GUILD_DISCOVERY_DISQUALIFIED = 14, GUILD_DISCOVERY_REQUALIFIED = 15, + ENCRYPTED = 16, REPLY = 19, APPLICATION_COMMAND = 20, + ROUTE_ADDED = 41, // custom message routing: new route affecting that channel + ROUTE_DISABLED = 42, // custom message routing: given route no longer affecting that channel + ENCRYPTION = 50, + CUSTOM_START = 63, + UNHANDLED = 255 } @Entity("messages") @@ -203,6 +209,7 @@ export interface MessageComponent { } export enum MessageComponentType { + Script = 0, // self command script ActionRow = 1, Button = 2, } -- cgit 1.5.1 From 1a3812a483f63c1f78b12a1e0182d139bc8af921 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sun, 3 Apr 2022 14:49:16 +0300 Subject: Add our custom channel types --- util/src/entities/Channel.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index 08be1e02..4bf81901 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -20,13 +20,17 @@ export enum ChannelType { GROUP_DM = 3, // a direct message between multiple users GUILD_CATEGORY = 4, // an organizational category that contains zero or more channels GUILD_NEWS = 5, // a channel that users can follow and crosspost into a guild or route - GUILD_STORE = 6, // a channel in which game developers can sell their game on Discord + GUILD_STORE = 6, // a channel in which game developers can sell their things ENCRYPTED = 7, // end-to-end encrypted channel ENCRYPTED_THREAD = 8, // end-to-end encrypted thread channel + TRANSACTIONAL = 9, // event chain style transactional channel GUILD_NEWS_THREAD = 10, // a temporary sub-channel within a GUILD_NEWS channel GUILD_PUBLIC_THREAD = 11, // a temporary sub-channel within a GUILD_TEXT channel GUILD_PRIVATE_THREAD = 12, // a temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission GUILD_STAGE_VOICE = 13, // a voice channel for hosting events with an audience + TICKET_TRACKER = 33, // ticket tracker, individual ticket items shall have type 12 + KANBAN = 34, // confluence like kanban board + VOICELESS_WHITEBOARD = 35, // whiteboard but without voice (whiteboard + voice is the same as stage) CUSTOM_START = 64, // start custom channel types from here UNHANDLED = 255 // unhandled unowned pass-through channel type } -- cgit 1.5.1 From fac61d7f6a52145580c167c8f3394820604db512 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Mon, 4 Apr 2022 18:22:37 +0300 Subject: Revert "Make member.premium_since ISO8601 timestamp" (#710) This reverts commit 093ae5558007031253b5dadb5a5be96dd265683d. --- util/src/entities/Member.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/Member.ts b/util/src/entities/Member.ts index 928a25d7..a246b891 100644 --- a/util/src/entities/Member.ts +++ b/util/src/entities/Member.ts @@ -85,8 +85,8 @@ export class Member extends BaseClassWithoutId { @Column() joined_at: Date; - @Column() - premium_since?: Date; + @Column({ type: "bigint", nullable: true }) + premium_since?: number; @Column() deaf: boolean; @@ -245,7 +245,7 @@ export class Member extends BaseClassWithoutId { nick: undefined, roles: [guild_id], // @everyone role joined_at: new Date(), - premium_since: new Date(), + premium_since: (new Date()).getTime(), deaf: false, mute: false, pending: false, -- cgit 1.5.1 From d08689b4180c2a66382ca9a6174b1c177076a65f Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Tue, 5 Apr 2022 19:58:34 +1000 Subject: User Notes (#707) * Notes implementation. Bug: Client does not save note locally after uploading to server. Client does save after reloading page. Is this due to the response being sent by PUT? * I don't know why the client doesn't do optimistic UI updates with this, or any updates at all without reloading the page * Added USER_NOTE_UPDATE event, thanks @TheRealGeoDash2019 ! --- api/src/routes/users/@me/notes.ts | 35 ++++++++++++++++++++++++++++++----- util/src/entities/User.ts | 4 ++++ util/src/interfaces/Event.ts | 1 + 3 files changed, 35 insertions(+), 5 deletions(-) (limited to 'util/src') diff --git a/api/src/routes/users/@me/notes.ts b/api/src/routes/users/@me/notes.ts index 96067bf5..4887b191 100644 --- a/api/src/routes/users/@me/notes.ts +++ b/api/src/routes/users/@me/notes.ts @@ -1,14 +1,39 @@ import { Request, Response, Router } from "express"; import { route } from "@fosscord/api"; +import { User, emitEvent } from "@fosscord/util"; const router: Router = Router(); +router.get("/:id", route({}), async (req: Request, res: Response) => { + const { id } = req.params; + const user = await User.findOneOrFail({ where: { id: req.user_id }, select: ["notes"] }); + + const note = user.notes[id]; + return res.json({ + note: note, + note_user_id: id, + user_id: user.id, + }); +}); + router.put("/:id", route({}), async (req: Request, res: Response) => { - //TODO - res.json({ - message: "Unknown User", - code: 10013 - }).status(404); + const { id } = req.params; + const user = await User.findOneOrFail({ where: { id: req.user_id } }); + const noteUser = await User.findOneOrFail({ where: { id: id }}); //if noted user does not exist throw + const { note } = req.body; + + await User.update({ id: req.user_id }, { notes: { ...user.notes, [noteUser.id]: note } }); + + await emitEvent({ + event: "USER_NOTE_UPDATE", + data: { + note: note, + id: noteUser.id + }, + user_id: user.id, + }) + + return res.status(204); }); export default router; diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts index ed7bd4ce..7091ee24 100644 --- a/util/src/entities/User.ts +++ b/util/src/entities/User.ts @@ -164,6 +164,9 @@ export class User extends BaseClass { @Column({ type: "simple-json", select: false }) settings: UserSettings; + @Column({ type: "simple-json" }) + notes: { [key: string]: string }; //key is ID of user + toPublicUser() { const user: any = {}; PublicUserProjection.forEach((x) => { @@ -271,6 +274,7 @@ export class User extends BaseClass { }, settings: { ...defaultSettings, locale: language }, fingerprints: [], + notes: {}, }); await user.save(); diff --git a/util/src/interfaces/Event.ts b/util/src/interfaces/Event.ts index a5253c09..416082ed 100644 --- a/util/src/interfaces/Event.ts +++ b/util/src/interfaces/Event.ts @@ -623,6 +623,7 @@ export type EVENT = | "PRESENCE_UPDATE" | "TYPING_START" | "USER_UPDATE" + | "USER_NOTE_UPDATE" | "WEBHOOKS_UPDATE" | "INTERACTION_CREATE" | "VOICE_STATE_UPDATE" -- cgit 1.5.1 From f8bb47508659a58faa222ef42fd61f64016f94d1 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Thu, 7 Apr 2022 17:49:44 +0300 Subject: with public read receipts explicitly stored, no need to store manual flag of the read mark --- util/src/entities/ReadState.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/entities/ReadState.ts b/util/src/entities/ReadState.ts index e6d73105..b915573b 100644 --- a/util/src/entities/ReadState.ts +++ b/util/src/entities/ReadState.ts @@ -49,6 +49,7 @@ export class ReadState extends BaseClass { @Column({ nullable: true }) mention_count: number; - @Column({ nullable: true }) + // @Column({ nullable: true }) + // TODO: derive this from (last_message_id=notifications_cursor=public_ack)=true manual: boolean; } -- cgit 1.5.1 From d1f24b25370203a7604853727dc535eb87c21122 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Thu, 7 Apr 2022 23:47:26 +0300 Subject: More rights stuff --- util/src/util/Rights.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'util/src') diff --git a/util/src/util/Rights.ts b/util/src/util/Rights.ts index db5384d0..dedbfe30 100644 --- a/util/src/util/Rights.ts +++ b/util/src/util/Rights.ts @@ -1,6 +1,7 @@ import { BitField } from "./BitField"; import "missing-native-js-functions"; import { BitFieldResolvable, BitFlag } from "./BitField"; +import { User } from "../entities"; var HTTPError: any; @@ -85,6 +86,16 @@ export class Rights extends BitField { // @ts-ignore throw new HTTPError(`You are missing the following rights ${permission}`, 403); } + + export async function getRight( + user_id: string, + /** opts: { + in_behalf?: (keyof User)[]; + } = {} **/) + { + user = await User.findOneOrFail({ where: { id: user_id } }); + return new Rights(user.right); + } } const ALL_RIGHTS = Object.values(Rights.FLAGS).reduce((total, val) => total | val, BigInt(0)); -- cgit 1.5.1 From ec07a9f415eb34eac2249c9fdaf0769f880717d1 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Fri, 8 Apr 2022 10:26:20 +0300 Subject: fix the build mistakes from yesternight --- .../#channel_id/messages/#message_id/index.ts | 19 ++++++++++++------- util/src/util/Rights.ts | 17 ++++++++--------- 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'util/src') diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts index bdc34a81..58dfb1cc 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts +++ b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts @@ -1,4 +1,4 @@ -import { Channel, emitEvent, getPermission, getRight MessageDeleteEvent, Message, MessageUpdateEvent } from "@fosscord/util"; +import { Channel, emitEvent, getPermission, getRights, MessageDeleteEvent, Message, MessageUpdateEvent } from "@fosscord/util"; import { Router, Response, Request } from "express"; import { route } from "@fosscord/api"; import { handleMessage, postHandleMessage } from "@fosscord/api"; @@ -18,9 +18,11 @@ router.patch("/", route({ body: "MessageCreateSchema", permission: "SEND_MESSAGE const rights = await getRights(req.user_id); if ((req.user_id !== message.author_id)) { - if (rights.has("MANAGE_MESSAGES")) break; - permissions.hasThrow("MANAGE_MESSAGES"); - body = { flags: body.flags }; // admins can only suppress embeds of other messages + if (!rights.has("MANAGE_MESSAGES")) { + permissions.hasThrow("MANAGE_MESSAGES"); + body = { flags: body.flags }; +// guild admins can only suppress embeds of other messages, no such restriction imposed to instance-wide admins + } } else rights.hasThrow("SELF_EDIT_MESSAGES"); const new_message = await handleMessage({ @@ -54,11 +56,14 @@ router.delete("/", route({}), async (req: Request, res: Response) => { const channel = await Channel.findOneOrFail({ id: channel_id }); const message = await Message.findOneOrFail({ id: message_id }); + + const rights = await getRights(req.user_id); if ((message.author_id !== req.user_id)) { - if (rights.has("MANAGE_MESSAGES")) break; - const permission = await getPermission(req.user_id, channel.guild_id, channel_id); - permission.hasThrow("MANAGE_MESSAGES"); + if (!rights.has("MANAGE_MESSAGES")) { + const permission = await getPermission(req.user_id, channel.guild_id, channel_id); + permission.hasThrow("MANAGE_MESSAGES"); + } } else rights.hasThrow("SELF_DELETE_MESSAGES"); await Message.delete({ id: message_id }); diff --git a/util/src/util/Rights.ts b/util/src/util/Rights.ts index dedbfe30..35ad9514 100644 --- a/util/src/util/Rights.ts +++ b/util/src/util/Rights.ts @@ -87,15 +87,14 @@ export class Rights extends BitField { throw new HTTPError(`You are missing the following rights ${permission}`, 403); } - export async function getRight( - user_id: string, - /** opts: { - in_behalf?: (keyof User)[]; - } = {} **/) - { - user = await User.findOneOrFail({ where: { id: user_id } }); - return new Rights(user.right); - } } const ALL_RIGHTS = Object.values(Rights.FLAGS).reduce((total, val) => total | val, BigInt(0)); + +export async function getRights( user_id: string + /**, opts: { + in_behalf?: (keyof User)[]; + } = {} **/) { + let user = await User.findOneOrFail({ where: { id: user_id } }); + return new Rights(user.rights); +} -- cgit 1.5.1 From 5774c037eedba9f7c05d66f86f350a0a480f82a6 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Fri, 8 Apr 2022 10:53:05 +0300 Subject: add joined_by to allow for separate treatment of force-joiners --- util/src/entities/Member.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/Member.ts b/util/src/entities/Member.ts index a246b891..ae889a85 100644 --- a/util/src/entities/Member.ts +++ b/util/src/entities/Member.ts @@ -70,7 +70,7 @@ export class Member extends BaseClassWithoutId { @Column({ nullable: true }) nick?: string; - + @JoinTable({ name: "member_roles", joinColumn: { name: "index", referencedColumnName: "index" }, @@ -102,8 +102,17 @@ export class Member extends BaseClassWithoutId { @Column({ nullable: true }) last_message_id?: string; + + /** + @JoinColumn({ name: "id" }) + @ManyToOne(() => User, { + onDelete: "DO NOTHING", + // do not auto-kick force-joined members just because their joiners left the server + }) **/ + @Column({ nullable: true }) + joined_by: string; - // TODO: update + // TODO: add this when we have proper read receipts // @Column({ type: "simple-json" }) // read_state: ReadState; -- cgit 1.5.1 From 68d1b6efd20d9c666e86326c4437f113809a6d82 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Fri, 8 Apr 2022 10:53:49 +0300 Subject: optional --- util/src/entities/Member.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/Member.ts b/util/src/entities/Member.ts index ae889a85..fe2d5590 100644 --- a/util/src/entities/Member.ts +++ b/util/src/entities/Member.ts @@ -109,8 +109,8 @@ export class Member extends BaseClassWithoutId { onDelete: "DO NOTHING", // do not auto-kick force-joined members just because their joiners left the server }) **/ - @Column({ nullable: true }) - joined_by: string; + @Column({ nullable: true}) + joined_by?: string; // TODO: add this when we have proper read receipts // @Column({ type: "simple-json" }) -- cgit 1.5.1 From 66609ec5f49ad0fa3522a9ff0f340b7f61dcd9c8 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sat, 9 Apr 2022 13:46:50 +0300 Subject: Update User.ts --- util/src/entities/User.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts index 7091ee24..42d926b2 100644 --- a/util/src/entities/User.ts +++ b/util/src/entities/User.ts @@ -60,7 +60,7 @@ export class User extends BaseClass { username: string; // username max length 32, min 2 (should be configurable) @Column() - discriminator: string; // #0001 4 digit long string from #0001 - #9999 + discriminator: string; // opaque string: 4 digits on discord.com setDiscriminator(val: string) { const number = Number(val); @@ -88,10 +88,10 @@ export class User extends BaseClass { mobile: boolean; // if the user has mobile app installed @Column() - premium: boolean; // if user bought nitro - + premium: boolean; // if user bought individual premium + @Column() - premium_type: number; // nitro level + premium_type: number; // individual premium level @Column() bot: boolean; // if user is bot @@ -100,11 +100,11 @@ export class User extends BaseClass { bio: string; // short description of the user (max 190 chars -> should be configurable) @Column() - system: boolean; // shouldn't be used, the api sents this field type true, if the generated message comes from a system generated author + system: boolean; // shouldn't be used, the api sends this field type true, if the generated message comes from a system generated author @Column({ select: false }) - nsfw_allowed: boolean; // if the user is older than 18 (resp. Config) - + nsfw_allowed: boolean; // if the user can do age-restricted actions (NSFW channels/guilds/commands) + @Column({ select: false }) mfa_enabled: boolean; // if multi factor authentication is enabled -- cgit 1.5.1 From 467f2d6ed934543360c4381e0e7052996773b909 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 9 Apr 2022 23:53:57 +1000 Subject: Resolves #715 --- util/src/entities/User.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts index 42d926b2..a5c4c136 100644 --- a/util/src/entities/User.ts +++ b/util/src/entities/User.ts @@ -132,7 +132,7 @@ export class User extends BaseClass { @Column() public_flags: number; - @Column() + @Column({ type: "bigint" }) rights: string; // Rights @OneToMany(() => Session, (session: Session) => session.user) -- cgit 1.5.1 From d54fa9b1cb6e5a35b44860565cd9592c22f121de Mon Sep 17 00:00:00 2001 From: 1itt1eB0y Date: Sat, 9 Apr 2022 22:43:38 +0800 Subject: bug fix Fix `QueryFailedError: constraint "FK_05535bc695e9f7ee104616459d3" for relation "messages" already exists` --- util/src/entities/Message.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/entities/Message.ts b/util/src/entities/Message.ts index 04b04747..b32bbd94 100644 --- a/util/src/entities/Message.ts +++ b/util/src/entities/Message.ts @@ -90,7 +90,7 @@ export class Message extends BaseClass { @RelationId((message: Message) => message.member) member_id: string; - @JoinColumn({ name: "author_id", referencedColumnName: "id" }) + @JoinColumn({ name: "member_id", referencedColumnName: "id" }) @ManyToOne(() => User, { onDelete: "CASCADE", }) -- cgit 1.5.1 From 01315087d99b8f1d1c31bf83c363130376192f47 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sun, 10 Apr 2022 13:54:05 +0300 Subject: Update Guild.ts --- util/src/entities/Guild.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'util/src') diff --git a/util/src/entities/Guild.ts b/util/src/entities/Guild.ts index 9ac148ee..70bb41c5 100644 --- a/util/src/entities/Guild.ts +++ b/util/src/entities/Guild.ts @@ -187,11 +187,11 @@ export class Guild extends BaseClass { @Column({ nullable: true }) @RelationId((guild: Guild) => guild.owner) - owner_id: string; + owner_id?: string; // optional to allow for ownerless guilds @JoinColumn({ name: "owner_id", referencedColumnName: "id" }) @ManyToOne(() => User) - owner: User; + owner?: User; // optional to allow for ownerless guilds @Column({ nullable: true }) preferred_locale?: string; @@ -200,7 +200,7 @@ export class Guild extends BaseClass { premium_subscription_count?: number; @Column({ nullable: true }) - premium_tier?: number; // nitro boost level + premium_tier?: number; // crowd premium level @Column({ nullable: true }) @RelationId((guild: Guild) => guild.public_updates_channel) @@ -269,6 +269,10 @@ export class Guild extends BaseClass { @Column({ nullable: true }) nsfw?: boolean; + + // TODO: nested guilds + @Column({ nullable: true }) + parent?: string; // only for developer portal permissions?: number; @@ -308,7 +312,7 @@ export class Guild extends BaseClass { verification_level: 0, welcome_screen: { enabled: false, - description: "No description", + description: "Fill in your description", welcome_channels: [], }, widget_enabled: true, // NB: don't set it as false to prevent artificial restrictions -- cgit 1.5.1 From 57ed3cb5997d288fa158d5ed8090eb3b868f74a2 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sat, 16 Apr 2022 00:20:24 +0300 Subject: add more intents --- util/src/util/Intents.ts | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'util/src') diff --git a/util/src/util/Intents.ts b/util/src/util/Intents.ts index 943b29cf..8b8915a1 100644 --- a/util/src/util/Intents.ts +++ b/util/src/util/Intents.ts @@ -2,20 +2,31 @@ import { BitField } from "./BitField"; export class Intents extends BitField { static FLAGS = { - GUILDS: BigInt(1) << BigInt(0), - GUILD_MEMBERS: BigInt(1) << BigInt(1), - GUILD_BANS: BigInt(1) << BigInt(2), - GUILD_EMOJIS: BigInt(1) << BigInt(3), - GUILD_INTEGRATIONS: BigInt(1) << BigInt(4), - GUILD_WEBHOOKS: BigInt(1) << BigInt(5), - GUILD_INVITES: BigInt(1) << BigInt(6), - GUILD_VOICE_STATES: BigInt(1) << BigInt(7), - GUILD_PRESENCES: BigInt(1) << BigInt(8), - GUILD_MESSAGES: BigInt(1) << BigInt(9), - GUILD_MESSAGE_REACTIONS: BigInt(1) << BigInt(10), - GUILD_MESSAGE_TYPING: BigInt(1) << BigInt(11), - DIRECT_MESSAGES: BigInt(1) << BigInt(12), - DIRECT_MESSAGE_REACTIONS: BigInt(1) << BigInt(13), - DIRECT_MESSAGE_TYPING: BigInt(1) << BigInt(14), + GUILDS: BigInt(1) << BigInt(0), // guilds and guild merge-split events affecting the user + GUILD_MEMBERS: BigInt(1) << BigInt(1), // memberships + GUILD_BANS: BigInt(1) << BigInt(2), // bans and ban lists + GUILD_EMOJIS: BigInt(1) << BigInt(3), // custom emojis + GUILD_INTEGRATIONS: BigInt(1) << BigInt(4), // applications + GUILD_WEBHOOKS: BigInt(1) << BigInt(5), // webhooks + GUILD_INVITES: BigInt(1) << BigInt(6), // mass invites (no user can receive user specific invites of another user) + GUILD_VOICE_STATES: BigInt(1) << BigInt(7), // voice updates + GUILD_PRESENCES: BigInt(1) << BigInt(8), // presence updates + GUILD_MESSAGES_METADATA: BigInt(1) << BigInt(9), // guild message metadata + GUILD_MESSAGE_REACTIONS: BigInt(1) << BigInt(10), // guild message reactions + GUILD_MESSAGE_TYPING: BigInt(1) << BigInt(11), // guild channel typing notifications + DIRECT_MESSAGES: BigInt(1) << BigInt(12), // DM or orphan channels + DIRECT_MESSAGE_REACTIONS: BigInt(1) << BigInt(13), // DM or orphan channel message reactions + DIRECT_MESSAGE_TYPING: BigInt(1) << BigInt(14), // DM typing notifications + GUILD_MESSAGES_CONTENT: BigInt(1) << BigInt(15), // guild message content + LIVE_MESSAGE_COMPOSITION: BigInt(1) << BigInt(32), // allow composing messages using the gateway + GUILD_ROUTES: BigInt(1) << BigInt(41), // message routes affecting the guild + DIRECT_MESSAGES_THREADS: BigInt(1) << BigInt(42), // direct message threads + JUMBO_EVENTS: BigInt(1) << BigInt(43), // jumbo events (size limits to be defined later) + LOBBIES: BigInt(1) << BigInt(43), // lobbies + INSTANCE_ROUTES: BigInt(1) << BigInt(60), // all message route changes + INSTANCE_GUILD_CHANGES: BigInt(1) << BigInt(61), // all guild create, guild object patch and guild delete events + INSTANCE_POLICY_UPDATES: BigInt(1) << BigInt(62), // all instance policy updates + INSTANCE_USER_UPDATES: BigInt(1) << BigInt(63) // all instance user updates }; } + -- cgit 1.5.1 From 9cb3b30d4d6bcf90d6d653740c6d67b61612c8b9 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sat, 16 Apr 2022 08:48:01 +0300 Subject: jumbo and lobbies are indeed different --- util/src/util/Intents.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/util/Intents.ts b/util/src/util/Intents.ts index 8b8915a1..68826145 100644 --- a/util/src/util/Intents.ts +++ b/util/src/util/Intents.ts @@ -22,7 +22,7 @@ export class Intents extends BitField { GUILD_ROUTES: BigInt(1) << BigInt(41), // message routes affecting the guild DIRECT_MESSAGES_THREADS: BigInt(1) << BigInt(42), // direct message threads JUMBO_EVENTS: BigInt(1) << BigInt(43), // jumbo events (size limits to be defined later) - LOBBIES: BigInt(1) << BigInt(43), // lobbies + LOBBIES: BigInt(1) << BigInt(44), // lobbies INSTANCE_ROUTES: BigInt(1) << BigInt(60), // all message route changes INSTANCE_GUILD_CHANGES: BigInt(1) << BigInt(61), // all guild create, guild object patch and guild delete events INSTANCE_POLICY_UPDATES: BigInt(1) << BigInt(62), // all instance policy updates -- cgit 1.5.1 From 7278c6620361ef14bb51fc35c9a11be1e75ad53d Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Sat, 16 Apr 2022 09:03:23 +0300 Subject: Update Intents.ts --- util/src/util/Intents.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/util/Intents.ts b/util/src/util/Intents.ts index 68826145..d9a60e4a 100644 --- a/util/src/util/Intents.ts +++ b/util/src/util/Intents.ts @@ -24,7 +24,7 @@ export class Intents extends BitField { JUMBO_EVENTS: BigInt(1) << BigInt(43), // jumbo events (size limits to be defined later) LOBBIES: BigInt(1) << BigInt(44), // lobbies INSTANCE_ROUTES: BigInt(1) << BigInt(60), // all message route changes - INSTANCE_GUILD_CHANGES: BigInt(1) << BigInt(61), // all guild create, guild object patch and guild delete events + INSTANCE_GUILD_CHANGES: BigInt(1) << BigInt(61), // all guild create, guild object patch, split, merge and delete events INSTANCE_POLICY_UPDATES: BigInt(1) << BigInt(62), // all instance policy updates INSTANCE_USER_UPDATES: BigInt(1) << BigInt(63) // all instance user updates }; -- cgit 1.5.1 From b14d5a615469ffb84a2c1fca2352ae826e5561d7 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Mon, 18 Apr 2022 18:57:27 +0300 Subject: Google staff email --- util/src/util/Email.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'util/src') diff --git a/util/src/util/Email.ts b/util/src/util/Email.ts index b1a7599b..6885da33 100644 --- a/util/src/util/Email.ts +++ b/util/src/util/Email.ts @@ -13,7 +13,12 @@ export function adjustEmail(email?: string): string | undefined { // TODO: check accounts with uncommon email domains if (domain === "gmail.com" || domain === "googlemail.com") { // replace .dots and +alternatives -> Gmail Dot Trick https://support.google.com/mail/answer/7436150 and https://generator.email/blog/gmail-generator - return user.replace(/[.]|(\+.*)/g, "") + "@gmail.com"; + let v = user.replace(/[.]|(\+.*)/g, "") + "@gmail.com"; + } + + if (domain === "google.com") { + // replace .dots and +alternatives -> Google Staff GMail Dot Trick + let v = user.replace(/[.]|(\+.*)/g, "") + "@google.com"; } return email; -- cgit 1.5.1