Removed playlist related functions from user and channel schemas.
This commit is contained in:
parent
7530b5fa5f
commit
70fc42b181
2 changed files with 0 additions and 142 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue