Browse Source

Verifying song now uses songId instead of youtubeId

Owen Diffey 3 years ago
parent
commit
0b2d93aaa4

+ 4 - 8
backend/logic/actions/songs.js

@@ -710,15 +710,15 @@ export default {
 	 * Verifies a song
 	 *
 	 * @param session
-	 * @param youtubeId - the youtube id
+	 * @param songId - the song id
 	 * @param cb
 	 */
-	verify: isAdminRequired(async function add(session, youtubeId, cb) {
+	verify: isAdminRequired(async function add(session, songId, cb) {
 		const SongModel = await DBModule.runJob("GET_MODEL", { modelName: "song" }, this);
 		async.waterfall(
 			[
 				next => {
-					SongModel.findOne({ youtubeId }, next);
+					SongModel.findOne({ _id: songId }, next);
 				},
 
 				(song, next) => {
@@ -756,11 +756,7 @@ export default {
 					return cb({ status: "error", message: err });
 				}
 
-				this.log(
-					"SUCCESS",
-					"SONGS_VERIFY",
-					`User "${session.userId}" successfully verified song "${youtubeId}".`
-				);
+				this.log("SUCCESS", "SONGS_VERIFY", `User "${session.userId}" successfully verified song "${songId}".`);
 
 				CacheModule.runJob("PUB", {
 					channel: "song.newVerifiedSong",

+ 6 - 7
frontend/src/components/modals/EditSong.vue

@@ -482,7 +482,7 @@
 					<button
 						v-if="song.status === 'unverified'"
 						class="button is-success"
-						@click="verify(song)"
+						@click="verify(song._id)"
 						content="Verify Song"
 						v-tippy
 					>
@@ -491,7 +491,7 @@
 					<confirm
 						v-if="song.status === 'verified'"
 						placement="left"
-						@confirm="unverify(song._id, index)"
+						@confirm="unverify(song._id)"
 					>
 						<button
 							class="button is-danger"
@@ -504,7 +504,7 @@
 					<confirm
 						v-if="song.status === 'unverified'"
 						placement="left"
-						@confirm="hide(song._id, index)"
+						@confirm="hide(song._id)"
 					>
 						<button
 							class="button is-danger"
@@ -1475,15 +1475,14 @@ export default {
 				this.activityWatchVideoLastStatus = "not_playing";
 			}
 		},
-		verify(song) {
-			this.socket.dispatch("songs.verify", song.youtubeId, res => {
+		verify(id) {
+			this.socket.dispatch("songs.verify", id, res => {
 				new Toast(res.message);
 			});
 		},
 		unverify(id) {
 			this.socket.dispatch("songs.unverify", id, res => {
-				if (res.status === "success") new Toast(res.message);
-				else new Toast(res.message);
+				new Toast(res.message);
 			});
 		},
 		hide(id) {

+ 3 - 3
frontend/src/pages/Admin/tabs/HiddenSongs.vue

@@ -96,7 +96,7 @@
 							</button>
 							<button
 								class="button is-success"
-								@click="unhide(song)"
+								@click="unhide(song._id)"
 								content="Unhide Song"
 								v-tippy
 							>
@@ -240,8 +240,8 @@ export default {
 			this.editSong(song);
 			this.openModal("editSong");
 		},
-		unhide(song) {
-			this.socket.dispatch("songs.unhide", song._id, res => {
+		unhide(id) {
+			this.socket.dispatch("songs.unhide", id, res => {
 				new Toast(res.message);
 			});
 		},

+ 4 - 7
frontend/src/pages/Admin/tabs/UnverifiedSongs.vue

@@ -96,16 +96,13 @@
 							</button>
 							<button
 								class="button is-success"
-								@click="verify(song)"
+								@click="verify(song._id)"
 								content="Verify Song"
 								v-tippy
 							>
 								<i class="material-icons">check_circle</i>
 							</button>
-							<confirm
-								placement="left"
-								@confirm="hide(song._id, index)"
-							>
+							<confirm placement="left" @confirm="hide(song._id)">
 								<button
 									class="button is-danger"
 									content="Hide Song"
@@ -256,8 +253,8 @@ export default {
 			this.editSong(song);
 			this.openModal("editSong");
 		},
-		verify(song) {
-			this.socket.dispatch("songs.verify", song.youtubeId, res => {
+		verify(id) {
+			this.socket.dispatch("songs.verify", id, res => {
 				new Toast(res.message);
 			});
 		},

+ 4 - 5
frontend/src/pages/Admin/tabs/VerifiedSongs.vue

@@ -80,7 +80,7 @@
 					</tr>
 				</thead>
 				<tbody>
-					<tr v-for="(song, index) in filteredSongs" :key="song._id">
+					<tr v-for="song in filteredSongs" :key="song._id">
 						<td>
 							<img
 								class="song-thumbnail"
@@ -125,7 +125,7 @@
 							</button>
 							<confirm
 								placement="left"
-								@confirm="remove(song._id, index)"
+								@confirm="unverify(song._id)"
 							>
 								<button
 									class="button is-danger"
@@ -348,10 +348,9 @@ export default {
 			this.editSong(song);
 			this.openModal("editSong");
 		},
-		remove(id) {
+		unverify(id) {
 			this.socket.dispatch("songs.unverify", id, res => {
-				if (res.status === "success") new Toast(res.message);
-				else new Toast(res.message);
+				new Toast(res.message);
 			});
 		},
 		getSet() {