diff --git a/src/models/community.ts b/src/models/community.ts index 292f1ef..99ee6b1 100644 --- a/src/models/community.ts +++ b/src/models/community.ts @@ -70,30 +70,6 @@ const CommunitySchema = new Schema('upEmpathy', async function upEmpathy(): Promise { - this.empathy_count += 1; - - await this.save(); -}); - -CommunitySchema.method('downEmpathy', async function downEmpathy(): Promise { - this.empathy_count -= 1; - - await this.save(); -}); - -CommunitySchema.method('upFollower', async function upFollower(): Promise { - this.followers += 1; - - await this.save(); -}); - -CommunitySchema.method('downFollower', async function downFollower(): Promise { - this.followers -= 1; - - await this.save(); -}); - CommunitySchema.method('addUserFavorite', async function addUserFavorite(pid: number): Promise { if (!this.user_favorites.includes(pid)) { this.user_favorites.push(pid); diff --git a/src/models/content.ts b/src/models/content.ts index ee63e37..bb0f968 100644 --- a/src/models/content.ts +++ b/src/models/content.ts @@ -1,5 +1,5 @@ import { Schema, model } from 'mongoose'; -import { IContent, IContentMethods, ContentModel, HydratedContentDocument } from '@/types/mongoose/content'; +import { IContent, IContentMethods, ContentModel } from '@/types/mongoose/content'; const ContentSchema = new Schema({ pid: Number, @@ -17,34 +17,4 @@ const ContentSchema = new Schema({ } }); -ContentSchema.method('addToCommunities', async function addToCommunities(postID) { - this.followed_communities.addToSet(postID); - await this.save(); -}); - -ContentSchema.method('removeFromCommunities', async function removeFromCommunities(postID) { - this.followed_communities.pull(postID); - await this.save(); -}); - -ContentSchema.method('addToUsers', async function addToUsers(postID) { - this.followed_users.addToSet(postID); - await this.save(); -}); - -ContentSchema.method('removeFromUsers', async function removeFromUsers(postID) { - this.followed_users.pull(postID); - await this.save(); -}); - -ContentSchema.method('addToFollowers', async function addToFollowers(postID) { - this.following_users.addToSet(postID); - await this.save(); -}); - -ContentSchema.method('removeFromFollowers', async function removeFromFollowers(postID) { - this.following_users.pull(postID); - await this.save(); -}); - export const Content = model('Content', ContentSchema); diff --git a/src/models/conversation.ts b/src/models/conversation.ts index c92b3c5..5991903 100644 --- a/src/models/conversation.ts +++ b/src/models/conversation.ts @@ -47,18 +47,4 @@ ConversationSchema.method('newMessage', async func await this.save(); }); -ConversationSchema.method('markAsRead', async function markAsRead(pid) { - const users = this.get('users'); - if (users[0].pid === pid) { - users[0].read = true; - } else if (users[1].pid === pid) { - users[1].read = true; - } - - this.users = users; - this.markModified('users'); - - await this.save(); -}); - export const Conversation = model('Conversation', ConversationSchema); \ No newline at end of file diff --git a/src/models/notification.ts b/src/models/notification.ts index 6e96f1d..ac7a50b 100644 --- a/src/models/notification.ts +++ b/src/models/notification.ts @@ -1,5 +1,5 @@ import { Schema, model } from 'mongoose'; -import { HydratedNotificationDocument, INotification, INotificationMethods, NotificationModel } from '@/types/mongoose/notification'; +import { INotification, INotificationMethods, NotificationModel } from '@/types/mongoose/notification'; const NotificationSchema = new Schema({ pid: String, @@ -14,9 +14,4 @@ const NotificationSchema = new Schema('markRead', async function markRead() { - this.read = true; - await this.save(); -}); - export const Notification = model('Notification', NotificationSchema); diff --git a/src/models/post.ts b/src/models/post.ts index 60fd0c8..e035a70 100644 --- a/src/models/post.ts +++ b/src/models/post.ts @@ -87,27 +87,6 @@ const PostSchema = new Schema({ id: false // * Disables the .id() getter used by Mongoose in TypeScript. Needed to have our own .id field }); -PostSchema.method('upReply', async function upReply() { - const replyCount = this.reply_count || 0; - if (replyCount + 1 < 0) { - this.reply_count = 0; - } else { - this.reply_count = replyCount + 1; - } - - await this.save(); -}); - -PostSchema.method('downReply', async function downReply() { - const replyCount = this.reply_count || 0; - if (replyCount - 1 < 0) { - this.reply_count = 0; - } else { - this.reply_count = replyCount - 1; - } - - await this.save(); -}); PostSchema.method('remove', async function remove(reason) { this.removed = true; @@ -115,12 +94,6 @@ PostSchema.method('remove', async function remove(reason) await this.save(); }); -PostSchema.method('unRemove', async function unRemove(reason) { - this.removed = false; - this.removed_reason = reason; - await this.save(); -}); - PostSchema.method('generatePostUID', async function generatePostUID(length: number) { const id = Buffer.from(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(length * 2))), 'binary').toString('base64').replace(/[+/]/g, '').substring(0, length); diff --git a/src/models/settings.ts b/src/models/settings.ts index 819ebb9..63c33c8 100644 --- a/src/models/settings.ts +++ b/src/models/settings.ts @@ -48,46 +48,6 @@ const SettingsSchema = new Schema({ } }); -SettingsSchema.method('updateComment', async function updateComment(comment) { - this.profile_comment = comment; - await this.save(); -}); - -SettingsSchema.method('updateSkill', async function updateSkill(skill) { - this.game_skill = skill; - await this.save(); -}); - -SettingsSchema.method('commentVisible', async function commentVisible(active) { - this.profile_comment_visibility = active; - await this.save(); -}); - -SettingsSchema.method('skillVisible', async function skillVisible(active) { - this.game_skill_visibility = active; - await this.save(); -}); - -SettingsSchema.method('birthdayVisible', async function birthdayVisible(active) { - this.birthday_visibility = active; - await this.save(); -}); - -SettingsSchema.method('relationshipVisible', async function relationshipVisible(active) { - this.relationship_visibility = active; - await this.save(); -}); - -SettingsSchema.method('countryVisible', async function countryVisible(active) { - this.country_visibility = active; - await this.save(); -}); - -SettingsSchema.method('favCommunityVisible', async function favCommunityVisible(active) { - this.profile_favorite_community_visibility = active; - await this.save(); -}); - SettingsSchema.method('json', function json(): Record { return { pid: this.pid, diff --git a/src/types/mongoose/community.ts b/src/types/mongoose/community.ts index 52ea2c7..0b94885 100644 --- a/src/types/mongoose/community.ts +++ b/src/types/mongoose/community.ts @@ -32,10 +32,6 @@ export interface ICommunity { } export interface ICommunityMethods { - upEmpathy(): Promise; - downEmpathy(): Promise; - upFollower(): Promise; - downFollower(): Promise; addUserFavorite(pid: number): Promise; delUserFavorite(pid: number): Promise; json(): Record; diff --git a/src/types/mongoose/content.ts b/src/types/mongoose/content.ts index d816ce2..5e7fd55 100644 --- a/src/types/mongoose/content.ts +++ b/src/types/mongoose/content.ts @@ -7,14 +7,7 @@ export interface IContent { following_users: Types.Array; } -export interface IContentMethods { - addToCommunities(): Promise - removeFromCommunities(): Promise - addToUsers(): Promise - removeFromUsers(): Promise - addToFollowers(): Promise - removeFromFollowers(): Promise -} +export interface IContentMethods {} interface IContentQueryHelpers {} diff --git a/src/types/mongoose/conversation.ts b/src/types/mongoose/conversation.ts index 727c834..dbf25e3 100644 --- a/src/types/mongoose/conversation.ts +++ b/src/types/mongoose/conversation.ts @@ -15,8 +15,7 @@ export interface IConversation { } export interface IConversationMethods { - newMessage(message: string, senderPID: number): Promise - markAsRead(pid: number): Promise + newMessage(message: string, senderPID: number): Promise; } interface IConversationQueryHelpers {} diff --git a/src/types/mongoose/notification.ts b/src/types/mongoose/notification.ts index e27d9e1..771051e 100644 --- a/src/types/mongoose/notification.ts +++ b/src/types/mongoose/notification.ts @@ -15,9 +15,7 @@ export interface INotification { lastUpdated: number; } -export interface INotificationMethods { - markRead(): Promise -} +export interface INotificationMethods {} interface INotificationQueryHelpers {} diff --git a/src/types/mongoose/post.ts b/src/types/mongoose/post.ts index f3b4d05..916e20e 100644 --- a/src/types/mongoose/post.ts +++ b/src/types/mongoose/post.ts @@ -40,10 +40,7 @@ export interface IPost { } export interface IPostMethods { - upReply(): Promise; - downReply(): Promise; remove(reason: string): Promise; - unRemove(reason: string): Promise; generatePostUID(length: number): Promise; cleanedBody(): string; cleanedMiiData(): string; diff --git a/src/types/mongoose/settings.ts b/src/types/mongoose/settings.ts index 14ffb12..c07e79c 100644 --- a/src/types/mongoose/settings.ts +++ b/src/types/mongoose/settings.ts @@ -18,15 +18,7 @@ export interface ISettings { } export interface ISettingsMethods { - updateComment(comment: string): Promise; - updateSkill(skill: number): Promise; - commentVisible(active: boolean): Promise; - skillVisible(active: boolean): Promise; - birthdayVisible(active: boolean): Promise; - relationshipVisible(active: boolean): Promise; - countryVisible(active: boolean): Promise; - favCommunityVisible(active: boolean): Promise; - json(): Record; + json(): Record; } interface ISettingsQueryHelpers {}