From 70fc42b181be16e1c272f8fe2e7f1733871ed142 Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Tue, 23 Jun 2026 04:02:10 -0400 Subject: [PATCH] Removed playlist related functions from user and channel schemas. --- src/schemas/channel/channelSchema.js | 71 ---------------------------- src/schemas/user/userSchema.js | 71 ---------------------------- 2 files changed, 142 deletions(-) diff --git a/src/schemas/channel/channelSchema.js b/src/schemas/channel/channelSchema.js index 27292b8..22fa78e 100644 --- a/src/schemas/channel/channelSchema.js +++ b/src/schemas/channel/channelSchema.js @@ -666,77 +666,6 @@ channelSchema.methods.getEmotes = function(){ return emoteList; } -/** - * Generates Network-Friendly Browser-Digestable list of channel playlists - * @returns {Array} Network-Friendly Browser-Digestable list of channel playlists - */ -channelSchema.methods.getPlaylists = function(){ - //Create an empty array to hold our emote list - const playlists = []; - - //For each channel emote - for(let playlist of this.media.playlists){ - //Push an object with select information from the emote to the emote list - playlists.push(playlist.dehydrate()); - } - - //return the emote list - return playlists; -} - -/** - * Crawls through channel playlists, running a given callback function against each one - * @param {Function} cb - Callback function to run against channel playlists - */ -channelSchema.methods.playlistCrawl = function(cb){ - for(let listIndex in this.media.playlists){ - //Grab the associated playlist - playlist = this.media.playlists[listIndex]; - - //Call the callback with the playlist and list index as arguments - cb(playlist, listIndex); - } -} - -/** - * Finds channel playlist by playlist name - * @param {String} name - name of given playlist to find - * @returns {Mongoose.Document} - Sub-Document representing a single playlist - */ -channelSchema.methods.getPlaylistByName = function(name){ - //Create null value to hold our found playlist - let foundPlaylist = null; - - //Crawl through active playlists - this.playlistCrawl((playlist, listIndex) => { - //If we found a match based on name - if(playlist.name == name){ - //Keep it - foundPlaylist = playlist; - //Pass down the list index - foundPlaylist.listIndex = listIndex; - } - }); - - //return the given playlist - return foundPlaylist; -} - -/** - * Deletes channel playlist by playlist name - * @param {String} name - name of given playlist to Delete - */ -channelSchema.methods.deletePlaylistByName = async function(name){ - //Find the playlist - let playlist = this.getPlaylistByName(name); - - //splice out the given playlist - this.media.playlists.splice(playlist.listIndex, 1); - - //save the channel document - await this.save(); -} - /** * Generates Network-Friendly Browser-Digestable list of Channel-Wide user bans * @returns {Array} Network-Friendly Browser-Digestable list of Channel-Wide user bans diff --git a/src/schemas/user/userSchema.js b/src/schemas/user/userSchema.js index 9f70938..b528cbf 100644 --- a/src/schemas/user/userSchema.js +++ b/src/schemas/user/userSchema.js @@ -662,77 +662,6 @@ userSchema.methods.deleteEmote = async function(name){ } } -/** - * Gets list of user playlists - * @returns {Array} Array of objects represnting a playlist containing media objects - */ -userSchema.methods.getPlaylists = function(){ - //Create an empty array to hold our emote list - const playlists = []; - - //For each channel emote - for(let playlist of this.playlists){ - //Push an object with select information from the emote to the emote list - playlists.push(playlist.dehydrate()); - } - - //return the emote list - return playlists; -} - -/** - * Iterates through user playlists and calls a given callback function against them - * @param {Function} cb - Callback function to call against user playlists - */ -userSchema.methods.playlistCrawl = function(cb){ - for(let listIndex in this.playlists){ - //Grab the associated playlist - playlist = this.playlists[listIndex]; - - //Call the callback with the playlist and list index as arguments - cb(playlist, listIndex); - } -} - -/** - * Returns playlist by name - * @param {String} name - Playlist to get by name - * @returns {Object} Object representing the requested playlist - */ -userSchema.methods.getPlaylistByName = function(name){ - //Create null value to hold our found playlist - let foundPlaylist = null; - - //Crawl through active playlists - this.playlistCrawl((playlist, listIndex) => { - //If we found a match based on name - if(playlist.name == name){ - //Keep it - foundPlaylist = playlist; - //Pass down the list index - foundPlaylist.listIndex = listIndex; - } - }); - - //return the given playlist - return foundPlaylist; -} - -/** - * Deletes a playlist from the user document by name - * @param {String} name - Name of playlist to delete - */ -userSchema.methods.deletePlaylistByName = async function(name){ - //Find the playlist - const playlist = this.getPlaylistByName(name); - - //splice out the given playlist - this.playlists.splice(playlist.listIndex, 1); - - //save the channel document - await this.save(); -} - /** * Salts, Hashes and Tattoo's IP address to user document in a privacy respecting manner * @param {String} ip - Plaintext IP Address to Salt, Hash and Tattoo