mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
- Introduces a new Music Library system for managing favorites (tracks, playlists, releases), replacing the previous TrackLike model. - Completely revamps the Studio TV profile page, adding live statistics, stream configuration, restream management, and media URL display. - Enhances the media player with a custom seekbar and improved audio playback logic for MPD and non-MPD sources. - Lays foundational groundwork for chat encryption with new models and APIs. - Refactors critical UI components like PlaylistView and PagePanel. - Standardizes monorepo development scripts to use npm. - Updates comty.js submodule and adds various new UI components.
33 lines
670 B
JavaScript
33 lines
670 B
JavaScript
import { Track } from "@db_models"
|
|
|
|
const allowedFields = ["title", "artist", "album", "cover", "public"]
|
|
|
|
export default async (track_id, payload) => {
|
|
if (!track_id) {
|
|
throw new OperationError(400, "Missing track_id")
|
|
}
|
|
|
|
const track = await Track.findById(track_id)
|
|
|
|
if (!track) {
|
|
throw new OperationError(404, "Track not found")
|
|
}
|
|
|
|
if (track.publisher.user_id !== payload.user_id) {
|
|
throw new PermissionError(
|
|
403,
|
|
"You dont have permission to edit this track",
|
|
)
|
|
}
|
|
|
|
for (const field of allowedFields) {
|
|
if (payload[field] !== undefined) {
|
|
track[field] = payload[field]
|
|
}
|
|
}
|
|
|
|
track.modified_at = Date.now()
|
|
|
|
return await track.save()
|
|
}
|