From 2991daaf13f9b16e3d4d8622db06f607ee541302 Mon Sep 17 00:00:00 2001 From: Behzad Rabiei <53224485+Behzad-rabiei@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:09:18 +0200 Subject: [PATCH 1/3] feat: extent the token schema to support Telegram platform --- package.json | 2 +- src/config/enums.ts | 1 + src/interfaces/Token.interface.ts | 1 + src/models/schemas/Token.schema.ts | 4 ++++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7c33029..2137315 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@togethercrew.dev/db", - "version": "3.0.77", + "version": "3.0.78", "description": "All interactions with DB", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/config/enums.ts b/src/config/enums.ts index 5668f65..6863907 100644 --- a/src/config/enums.ts +++ b/src/config/enums.ts @@ -36,4 +36,5 @@ export enum TokenTypeNames { GOOGLE_ACCESS = 'google_access', GOOGLE_REFRESH = 'google_refresh', NOTION_ACCESS = 'notion_access', + TELEGRAM_VERIFICATION = 'telegram_verification' } diff --git a/src/interfaces/Token.interface.ts b/src/interfaces/Token.interface.ts index d235655..e28f8a4 100644 --- a/src/interfaces/Token.interface.ts +++ b/src/interfaces/Token.interface.ts @@ -4,6 +4,7 @@ import { type TokenTypeNames } from '../config/enums'; export interface IToken { token: string; user: Types.ObjectId; + community: Types.ObjectId; type: TokenTypeNames; expires: Date; blacklisted?: boolean; diff --git a/src/models/schemas/Token.schema.ts b/src/models/schemas/Token.schema.ts index fb8b7d6..6b00b0e 100644 --- a/src/models/schemas/Token.schema.ts +++ b/src/models/schemas/Token.schema.ts @@ -15,6 +15,10 @@ const tokenSchema = new Schema( ref: 'User', required: true, }, + community: { + type: Schema.Types.ObjectId, + ref: 'Community', + }, type: { type: String, enum: Object.values(TokenTypeNames), From efc6d30b20204a85897eeaecc7e74f7ff60ae51f Mon Sep 17 00:00:00 2001 From: Behzad Rabiei <53224485+Behzad-rabiei@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:22:04 +0200 Subject: [PATCH 2/3] feat: extent the token schema to support Telegram platform --- src/config/enums.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/enums.ts b/src/config/enums.ts index 6863907..d31a483 100644 --- a/src/config/enums.ts +++ b/src/config/enums.ts @@ -36,5 +36,5 @@ export enum TokenTypeNames { GOOGLE_ACCESS = 'google_access', GOOGLE_REFRESH = 'google_refresh', NOTION_ACCESS = 'notion_access', - TELEGRAM_VERIFICATION = 'telegram_verification' + TELEGRAM_VERIFICATION = 'telegram_verification', } From 3a4a64d2e8491890d7afc60952daa3ad7d659039 Mon Sep 17 00:00:00 2001 From: Behzad Rabiei <53224485+Behzad-rabiei@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:31:08 +0200 Subject: [PATCH 3/3] fix: correct the interface --- src/interfaces/Token.interface.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interfaces/Token.interface.ts b/src/interfaces/Token.interface.ts index e28f8a4..8ebbf91 100644 --- a/src/interfaces/Token.interface.ts +++ b/src/interfaces/Token.interface.ts @@ -4,7 +4,7 @@ import { type TokenTypeNames } from '../config/enums'; export interface IToken { token: string; user: Types.ObjectId; - community: Types.ObjectId; + community?: Types.ObjectId; type: TokenTypeNames; expires: Date; blacklisted?: boolean;