Updated archivedMediaSchema to track channel by DB identifier instead of name.

This commit is contained in:
rainbow napkin 2026-07-06 01:06:55 -04:00
parent 0dda73cd14
commit a07edfc842
3 changed files with 11 additions and 10 deletions

View file

@ -777,7 +777,7 @@ class queue{
if(media == null){
try{
//Attempt to delete matching item from archived media
const deletedArchive = await archivedMediaModel.deleteOne({channel: this.channel.name, uuid: new BSON.UUID(uuid)});
const deletedArchive = await archivedMediaModel.deleteOne({channel: this.channel._id, uuid: new BSON.UUID(uuid)});
//if nothing got deleted
if(deletedArchive == null || deletedArchive.deletedCount == 0){
@ -1850,7 +1850,7 @@ class queue{
this.scheduleMedia([archivedMediaObject], null, chanDB, true, true, true);
//Splice the fucker out of the archive
await archivedMediaModel.deleteOne({channel: this.channel.name, uuid: new BSON.UUID(chanDB.media.liveRemainder)});
await archivedMediaModel.deleteOne({channel: this.channel._id, uuid: new BSON.UUID(chanDB.media.liveRemainder)});
}
//Break out of the loop
@ -1880,7 +1880,7 @@ class queue{
*/
async archiveMedia(media){
//Convert queuedMedia object to archivedMedia object
let archived = archivedMedia.fromQueuedMedia(media, this.channel.name);
let archived = archivedMedia.fromQueuedMedia(media, this.channel._id);
//Save archivedMedia object to site-wide media archive (gross but performant)
let archivedDoc = await archivedMediaModel.create(archived);
}
@ -1893,14 +1893,14 @@ class queue{
if(startDate != null){
//Return archived media after start date
return await archivedMediaModel.find({
channel:this.channel.name,
channel:this.channel._id,
//Prevent mongoose from attempting to sanatize and invalidate our query object, plus I think we can trust an epoch that came from server-side :)
startTime: mongoose.trusted({$gt: startDate.getTime()})
});
//Otherwise
}else{
//return all archived media
return await archivedMediaModel.find({channel:this.channel.name});
return await archivedMediaModel.find({channel:this.channel._id});
}
}
}