/*Canopy - The next generation of stoner streaming software Copyright (C) 2024-2025 Rainbownapkin and the TTN Community This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see .*/ //NPM Imports const {mongoose} = require('mongoose'); /** * Rank Enum, lists all known permission ranks from lowest to highest. * * This originally belonged to the permissionSchema, but this avoids circular dependencies. */ const rankEnum = ["anon", "user", "gold", "bot", "mod", "admin"]; //Since this is intended to be used as a child schema for multiple parent schemas, we won't export it as a model /** * DB Schema for Sub-Document representing permission structure for a single channel */ const channelPermissionSchema = new mongoose.Schema({ manageChannel: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, changeRank: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, changePerms: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, changeSettings: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, kickUser: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, banUser: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, announce: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, clearChat: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, editTokeCommands: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, editEmotes: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, scheduleMedia: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, clearSchedule:{ type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, scheduleAdmin:{ type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, editChannelPlaylists:{ type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true }, deleteChannel: { type: mongoose.SchemaTypes.String, enum: rankEnum, default: "admin", required: true } }); //Only putting the rank enum out, all other logic should be handled by channelSchema methods to avoid circular dependencies //Alternatively if things get to big we can make it it's own util. channelPermissionSchema.statics.rankEnum = rankEnum; module.exports = channelPermissionSchema;