Compare commits
No commits in common. "df0cc26e710edc3784f46b72cd6c9b707525d98e" and "ab90aba67b4036603692a5bcec214eec84ac72fb" have entirely different histories.
df0cc26e71
...
ab90aba67b
@ -120,15 +120,14 @@ router.route("/:id/share")
|
|||||||
.post(passport.authenticate("jwt", { session: false }), (req, res) => {
|
.post(passport.authenticate("jwt", { session: false }), (req, res) => {
|
||||||
let album_id = req.params.id
|
let album_id = req.params.id
|
||||||
process.stdout.write("router/album POST albums share " + album_id + "\n");
|
process.stdout.write("router/album POST albums share " + album_id + "\n");
|
||||||
database.albums.byId(album_id, undefined, (album) => {
|
database.albums.byId(album_id, undefined, (result) => {
|
||||||
if (album != undefined && req.user.roles.indexOf("admin") > -1) {
|
if (result != undefined && req.user.roles.indexOf("admin") > -1) {
|
||||||
database.share.exists(album_id, result => {
|
database.share.exists(album_id, result => {
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
let item = {
|
let item = {
|
||||||
user_id: req.user._id,
|
user_id: req.user._id,
|
||||||
object_id: new ObjectId(album_id),
|
object_id: new ObjectId(album_id),
|
||||||
type: "album",
|
type: "album"
|
||||||
cover: album.covers.cover32
|
|
||||||
}
|
}
|
||||||
database.share.add(item, (result) => {
|
database.share.add(item, (result) => {
|
||||||
res.json(result).status(200).end();
|
res.json(result).status(200).end();
|
||||||
|
@ -122,15 +122,14 @@ router.route("/:id/share")
|
|||||||
.post(passport.authenticate("jwt", { session: false }), (req, res) => {
|
.post(passport.authenticate("jwt", { session: false }), (req, res) => {
|
||||||
let box_id = req.params.id
|
let box_id = req.params.id
|
||||||
process.stdout.write("router/box POST box share " + box_id + "\n");
|
process.stdout.write("router/box POST box share " + box_id + "\n");
|
||||||
database.boxes.byId(box_id, undefined, (box) => {
|
database.boxes.byId(box_id, undefined, (result) => {
|
||||||
if (box != undefined && req.user.roles.indexOf("admin") > -1) {
|
if (result != undefined && req.user.roles.indexOf("admin") > -1) {
|
||||||
database.share.exists(box_id, result => {
|
database.share.exists(box_id, result => {
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
let item = {
|
let item = {
|
||||||
user_id: req.user._id,
|
user_id: req.user._id,
|
||||||
object_id: new ObjectId(box_id),
|
object_id: new ObjectId(box_id),
|
||||||
type: "box",
|
type: "box"
|
||||||
cover: box.covers.cover32
|
|
||||||
}
|
}
|
||||||
database.share.add(item, (result) => {
|
database.share.add(item, (result) => {
|
||||||
res.json(result).status(200).end();
|
res.json(result).status(200).end();
|
||||||
|
@ -15,6 +15,7 @@ let box_project = {
|
|||||||
"videos.box_id": false,
|
"videos.box_id": false,
|
||||||
"videos.mime": false,
|
"videos.mime": false,
|
||||||
path: false,
|
path: false,
|
||||||
|
"covers.cover32": false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let boxes_project = {
|
let boxes_project = {
|
||||||
|
@ -45,7 +45,6 @@ exports.byId = function (id, callback) {
|
|||||||
exports.collection = function (callback) {
|
exports.collection = function (callback) {
|
||||||
dbo.collection("shares")
|
dbo.collection("shares")
|
||||||
.find({})
|
.find({})
|
||||||
.sort({ type: 1 })
|
|
||||||
.toArray((err, result) => {
|
.toArray((err, result) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
cb(callback, result);
|
cb(callback, result);
|
||||||
@ -56,7 +55,7 @@ exports.exists = function (object_id, callback) {
|
|||||||
dbo.collection("shares")
|
dbo.collection("shares")
|
||||||
.findOne({ object_id: ObjectId(object_id) })
|
.findOne({ object_id: ObjectId(object_id) })
|
||||||
.then(result => {
|
.then(result => {
|
||||||
cp(callback, result);
|
callback(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +74,7 @@ exports.add = function (item, callback) {
|
|||||||
])
|
])
|
||||||
.toArray((err, result) => {
|
.toArray((err, result) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
cp(callback, result[0]);
|
callback(result[0]);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user