diff --git a/api/src/models/Track.js b/api/src/models/Track.js index c45ee85..1d68260 100644 --- a/api/src/models/Track.js +++ b/api/src/models/Track.js @@ -55,8 +55,12 @@ const schema = new mongoose.Schema( // A user-provided description of the track. May contain markdown. description: String, - // Whether this track is visible in the public track list or not. - visible: Boolean, + // Whether this track is visible (anonymized) in the public track list or not. + public: { type: Boolean, default: false }, + + // Whether this track should be exported to the public track database + // (after anonymization). + includeInPublicDatabase: { type: Boolean, default: false }, // The user agent string, or a part thereof, that was used to upload this // track. Usually contains only the OBS version, other user agents are @@ -142,7 +146,7 @@ class Track extends mongoose.Model { } isVisibleTo(user) { - if (this.visible) { + if (this.public) { return true; } @@ -250,7 +254,7 @@ class Track extends mongoose.Model { description: this.description, createdAt: this.createdAt, updatedAt: this.updatedAt, - visible: this.visible, + public: this.public, author: this.author.toProfileJSONFor(user), statistics: this.statistics, processingStatus: this.processingStatus, diff --git a/api/src/routes/api/stats.js b/api/src/routes/api/stats.js index 11d4432..609faf3 100644 --- a/api/src/routes/api/stats.js +++ b/api/src/routes/api/stats.js @@ -11,7 +11,7 @@ router.get( '/', wrapRoute(async (req, res) => { const trackCount = await Track.find().count(); - const publicTrackCount = await Track.find({ visible: true }).count(); + const publicTrackCount = await Track.find({ public: true }).count(); const userCount = await User.find().count(); const [{ trackLength, numEvents, trackDuration }] = await Track.aggregate([ diff --git a/api/src/routes/api/tracks.js b/api/src/routes/api/tracks.js index 6f8b3b6..ab08f26 100644 --- a/api/src/routes/api/tracks.js +++ b/api/src/routes/api/tracks.js @@ -57,7 +57,7 @@ router.get( '/', auth.optional, wrapRoute(async (req, res) => { - const query = { visible: true }; + const query = { public: true }; let limit = 20; let offset = 0; @@ -183,12 +183,12 @@ router.post( // TODO: Stream into temporary file, then move it later. const { body, fileInfo } = await getMultipartOrJsonBody(req, (body) => body.track); - const { body: fileBody, visible, ...trackBody } = body + const { body: fileBody, public, ...trackBody } = body const track = new Track({ ...trackBody, author: req.user, - visible: visible == null ? req.user.areTracksVisibleForAll : Boolean(trackBody.visible) + public: public == null ? req.user.areTracksVisibleForAll : Boolean(trackBody.public) }) track.customizedTitle = track.title != null track.slugify(); @@ -249,10 +249,10 @@ router.put( let process = false - if (trackBody.visible != null) { - const visible = Boolean(trackBody.visible); - process |= visible !== track.visible - track.visible = visible + if (trackBody.public != null) { + const public = Boolean(trackBody.public); + process |= public !== track.public + track.public = public } if (fileBody) { diff --git a/frontend/src/pages/TrackEditor.tsx b/frontend/src/pages/TrackEditor.tsx index 62e0962..50bb118 100644 --- a/frontend/src/pages/TrackEditor.tsx +++ b/frontend/src/pages/TrackEditor.tsx @@ -114,13 +114,13 @@ const TrackEditor = connect((state) => ({login: state.login}))(function TrackEdi