diff --git a/package-lock.json b/package-lock.json
index 529af711..fb6be82b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -7,7 +7,7 @@
"": {
"name": "@fosscord/server-util",
"version": "1.3.13",
- "license": "ISC",
+ "license": "GPLV3",
"dependencies": {
"@types/jsonwebtoken": "^8.5.0",
"@types/mongoose-autopopulate": "^0.10.1",
@@ -18,7 +18,7 @@
"env-paths": "^2.2.1",
"jsonwebtoken": "^8.5.1",
"missing-native-js-functions": "^1.2.2",
- "mongodb": "^3.6.8",
+ "mongodb": "^3.6.9",
"mongoose": "^5.12.3",
"mongoose-autopopulate": "^0.12.3",
"typescript": "^4.1.3"
@@ -284,9 +284,9 @@
"integrity": "sha512-kNdwKWXh1hM8RdNqW2BIHsqD6fYN9RV27M+0uQF1pGF1yLKVc+xIv1VB8WEN1HxQ22N8Rj9sdEezOX2yBpsMZA=="
},
"node_modules/mongodb": {
- "version": "3.6.8",
- "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.8.tgz",
- "integrity": "sha512-sDjJvI73WjON1vapcbyBD3Ao9/VN3TKYY8/QX9EPbs22KaCSrQ5rXo5ZZd44tWJ3wl3FlnrFZ+KyUtNH6+1ZPQ==",
+ "version": "3.6.9",
+ "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.9.tgz",
+ "integrity": "sha512-1nSCKgSunzn/CXwgOWgbPHUWOO5OfERcuOWISmqd610jn0s8BU9K4879iJVabqgpPPbA6hO7rG48eq+fGED3Mg==",
"dependencies": {
"bl": "^2.2.1",
"bson": "^1.1.4",
@@ -805,9 +805,9 @@
"integrity": "sha512-kNdwKWXh1hM8RdNqW2BIHsqD6fYN9RV27M+0uQF1pGF1yLKVc+xIv1VB8WEN1HxQ22N8Rj9sdEezOX2yBpsMZA=="
},
"mongodb": {
- "version": "3.6.8",
- "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.8.tgz",
- "integrity": "sha512-sDjJvI73WjON1vapcbyBD3Ao9/VN3TKYY8/QX9EPbs22KaCSrQ5rXo5ZZd44tWJ3wl3FlnrFZ+KyUtNH6+1ZPQ==",
+ "version": "3.6.9",
+ "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.9.tgz",
+ "integrity": "sha512-1nSCKgSunzn/CXwgOWgbPHUWOO5OfERcuOWISmqd610jn0s8BU9K4879iJVabqgpPPbA6hO7rG48eq+fGED3Mg==",
"requires": {
"bl": "^2.2.1",
"bson": "^1.1.4",
diff --git a/package.json b/package.json
index 81e908d6..afcc6766 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
"env-paths": "^2.2.1",
"jsonwebtoken": "^8.5.1",
"missing-native-js-functions": "^1.2.2",
- "mongodb": "^3.6.8",
+ "mongodb": "^3.6.9",
"mongoose": "^5.12.3",
"mongoose-autopopulate": "^0.12.3",
"typescript": "^4.1.3"
diff --git a/src/models/Event.ts b/src/models/Event.ts
index 635adc46..8c692be1 100644
--- a/src/models/Event.ts
+++ b/src/models/Event.ts
@@ -1,4 +1,4 @@
-import { ConnectedAccount, PublicUser, User, UserSettings } from "./User";
+import { ConnectedAccount, PublicUser, Relationship, User, UserSettings } from "./User";
import { DMChannel, Channel } from "./Channel";
import { Guild } from "./Guild";
import { Member, PublicMember, UserGuildSettings } from "./Member";
@@ -49,7 +49,7 @@ export interface ReadyEventData {
user: PublicUser & {
mobile: boolean;
desktop: boolean;
- email: string | null ;
+ email: string | null;
flags: bigint;
mfa_enabled: boolean;
nsfw_allowed: boolean;
@@ -431,6 +431,19 @@ export interface MessageAckEvent extends Event {
};
}
+export interface RelationshipAddEvent extends Event {
+ event: "RELATIONSHIP_ADD";
+ data: Relationship & {
+ should_notify?: boolean;
+ user: PublicUser;
+ };
+}
+
+export interface RelationshipRemoveEvent extends Event {
+ event: "RELATIONSHIP_REMOVE";
+ data: Omit<Relationship, "nickname">;
+}
+
// located in collection events
export enum EVENTEnum {
@@ -520,6 +533,8 @@ export type EVENT =
| "APPLICATION_COMMAND_UPDATE"
| "APPLICATION_COMMAND_DELETE"
| "MESSAGE_ACK"
+ | "RELATIONSHIP_ADD"
+ | "RELATIONSHIP_REMOVE"
| CUSTOMEVENTS;
export type CUSTOMEVENTS = "INVALIDATED";
diff --git a/src/models/User.ts b/src/models/User.ts
index 76922903..31f91a4b 100644
--- a/src/models/User.ts
+++ b/src/models/User.ts
@@ -80,8 +80,14 @@ export interface ConnectedAccount {
export interface Relationship {
id: string;
nickname?: string;
- type: number;
- user_id: string;
+ type: RelationshipType;
+}
+
+export enum RelationshipType {
+ outgoing = 4,
+ incoming = 3,
+ blocked = 2,
+ friends = 1,
}
export interface UserSettings {
@@ -158,10 +164,9 @@ export const UserSchema = new Schema({
valid_tokens_since: Date, // all tokens with a previous issue date are invalid
relationships: [
{
- id: String,
+ id: { type: String, required: true },
nickname: String,
type: { type: Number },
- user_id: String,
},
],
connected_accounts: [
|