Relationship types

This commit is contained in:
Flam3rboy 2021-05-30 20:24:45 +02:00
parent 5460419cd8
commit 0ff1daeaff
4 changed files with 35 additions and 15 deletions

16
package-lock.json generated
View File

@ -7,7 +7,7 @@
"": { "": {
"name": "@fosscord/server-util", "name": "@fosscord/server-util",
"version": "1.3.13", "version": "1.3.13",
"license": "ISC", "license": "GPLV3",
"dependencies": { "dependencies": {
"@types/jsonwebtoken": "^8.5.0", "@types/jsonwebtoken": "^8.5.0",
"@types/mongoose-autopopulate": "^0.10.1", "@types/mongoose-autopopulate": "^0.10.1",
@ -18,7 +18,7 @@
"env-paths": "^2.2.1", "env-paths": "^2.2.1",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"missing-native-js-functions": "^1.2.2", "missing-native-js-functions": "^1.2.2",
"mongodb": "^3.6.8", "mongodb": "^3.6.9",
"mongoose": "^5.12.3", "mongoose": "^5.12.3",
"mongoose-autopopulate": "^0.12.3", "mongoose-autopopulate": "^0.12.3",
"typescript": "^4.1.3" "typescript": "^4.1.3"
@ -284,9 +284,9 @@
"integrity": "sha512-kNdwKWXh1hM8RdNqW2BIHsqD6fYN9RV27M+0uQF1pGF1yLKVc+xIv1VB8WEN1HxQ22N8Rj9sdEezOX2yBpsMZA==" "integrity": "sha512-kNdwKWXh1hM8RdNqW2BIHsqD6fYN9RV27M+0uQF1pGF1yLKVc+xIv1VB8WEN1HxQ22N8Rj9sdEezOX2yBpsMZA=="
}, },
"node_modules/mongodb": { "node_modules/mongodb": {
"version": "3.6.8", "version": "3.6.9",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.8.tgz", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.9.tgz",
"integrity": "sha512-sDjJvI73WjON1vapcbyBD3Ao9/VN3TKYY8/QX9EPbs22KaCSrQ5rXo5ZZd44tWJ3wl3FlnrFZ+KyUtNH6+1ZPQ==", "integrity": "sha512-1nSCKgSunzn/CXwgOWgbPHUWOO5OfERcuOWISmqd610jn0s8BU9K4879iJVabqgpPPbA6hO7rG48eq+fGED3Mg==",
"dependencies": { "dependencies": {
"bl": "^2.2.1", "bl": "^2.2.1",
"bson": "^1.1.4", "bson": "^1.1.4",
@ -805,9 +805,9 @@
"integrity": "sha512-kNdwKWXh1hM8RdNqW2BIHsqD6fYN9RV27M+0uQF1pGF1yLKVc+xIv1VB8WEN1HxQ22N8Rj9sdEezOX2yBpsMZA==" "integrity": "sha512-kNdwKWXh1hM8RdNqW2BIHsqD6fYN9RV27M+0uQF1pGF1yLKVc+xIv1VB8WEN1HxQ22N8Rj9sdEezOX2yBpsMZA=="
}, },
"mongodb": { "mongodb": {
"version": "3.6.8", "version": "3.6.9",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.8.tgz", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.9.tgz",
"integrity": "sha512-sDjJvI73WjON1vapcbyBD3Ao9/VN3TKYY8/QX9EPbs22KaCSrQ5rXo5ZZd44tWJ3wl3FlnrFZ+KyUtNH6+1ZPQ==", "integrity": "sha512-1nSCKgSunzn/CXwgOWgbPHUWOO5OfERcuOWISmqd610jn0s8BU9K4879iJVabqgpPPbA6hO7rG48eq+fGED3Mg==",
"requires": { "requires": {
"bl": "^2.2.1", "bl": "^2.2.1",
"bson": "^1.1.4", "bson": "^1.1.4",

View File

@ -35,7 +35,7 @@
"env-paths": "^2.2.1", "env-paths": "^2.2.1",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"missing-native-js-functions": "^1.2.2", "missing-native-js-functions": "^1.2.2",
"mongodb": "^3.6.8", "mongodb": "^3.6.9",
"mongoose": "^5.12.3", "mongoose": "^5.12.3",
"mongoose-autopopulate": "^0.12.3", "mongoose-autopopulate": "^0.12.3",
"typescript": "^4.1.3" "typescript": "^4.1.3"

View File

@ -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 { DMChannel, Channel } from "./Channel";
import { Guild } from "./Guild"; import { Guild } from "./Guild";
import { Member, PublicMember, UserGuildSettings } from "./Member"; import { Member, PublicMember, UserGuildSettings } from "./Member";
@ -49,7 +49,7 @@ export interface ReadyEventData {
user: PublicUser & { user: PublicUser & {
mobile: boolean; mobile: boolean;
desktop: boolean; desktop: boolean;
email: string | null ; email: string | null;
flags: bigint; flags: bigint;
mfa_enabled: boolean; mfa_enabled: boolean;
nsfw_allowed: 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 // located in collection events
export enum EVENTEnum { export enum EVENTEnum {
@ -520,6 +533,8 @@ export type EVENT =
| "APPLICATION_COMMAND_UPDATE" | "APPLICATION_COMMAND_UPDATE"
| "APPLICATION_COMMAND_DELETE" | "APPLICATION_COMMAND_DELETE"
| "MESSAGE_ACK" | "MESSAGE_ACK"
| "RELATIONSHIP_ADD"
| "RELATIONSHIP_REMOVE"
| CUSTOMEVENTS; | CUSTOMEVENTS;
export type CUSTOMEVENTS = "INVALIDATED"; export type CUSTOMEVENTS = "INVALIDATED";

View File

@ -80,8 +80,14 @@ export interface ConnectedAccount {
export interface Relationship { export interface Relationship {
id: string; id: string;
nickname?: string; nickname?: string;
type: number; type: RelationshipType;
user_id: string; }
export enum RelationshipType {
outgoing = 4,
incoming = 3,
blocked = 2,
friends = 1,
} }
export interface UserSettings { 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 valid_tokens_since: Date, // all tokens with a previous issue date are invalid
relationships: [ relationships: [
{ {
id: String, id: { type: String, required: true },
nickname: String, nickname: String,
type: { type: Number }, type: { type: Number },
user_id: String,
}, },
], ],
connected_accounts: [ connected_accounts: [