Marketplace and Friend updates
This commit is contained in:
parent
2224eaf7ee
commit
134ddd0d2a
|
@ -379,37 +379,37 @@ router.post('/upload/0', auth, limiter, async (req, res, next) => {
|
|||
let img3 = cryptoRandomString({length: 32})
|
||||
let img4 = img3
|
||||
console.log(storage)
|
||||
if(req.userData.admin) {
|
||||
var marketplace = await Item.create({
|
||||
name: req.body.name,
|
||||
UserId: user.id,
|
||||
sourceFile: "1",
|
||||
previewFile: img4,
|
||||
limited: req.body.limited,
|
||||
salePrice: req.body.onSalePrice,
|
||||
saleEnabled: req.body.onSale,
|
||||
price: req.body.price,
|
||||
quantityAllowed: req.body.quantityAllowed,
|
||||
approved: false,
|
||||
ItemCategoryId: findCategory.id,
|
||||
description: req.body.description
|
||||
})
|
||||
} else {
|
||||
var marketplace = await Item.create({
|
||||
name: req.body.name,
|
||||
UserId: user.id,
|
||||
sourceFile: req.file.filename,
|
||||
previewFile: img4,
|
||||
limited: false,
|
||||
salePrice: req.body.onSalePrice,
|
||||
saleEnabled: req.body.onSale,
|
||||
price: req.body.price,
|
||||
quantityAllowed: 0,
|
||||
approved: false,
|
||||
ItemCategoryId: findCategory.id,
|
||||
description: req.body.description
|
||||
})
|
||||
}
|
||||
if (req.userData.admin) {
|
||||
var marketplace = Item.create({
|
||||
name: field.name,
|
||||
UserId: user.id,
|
||||
sourceFile: "1",
|
||||
previewFile: img4,
|
||||
limited: field.limited,
|
||||
salePrice: field.onSalePrice,
|
||||
saleEnabled: field.onSale,
|
||||
price: field.price,
|
||||
quantityAllowed: field.quantityAllowed,
|
||||
approved: false,
|
||||
ItemCategoryId: findCategory.id,
|
||||
description: form.field.description
|
||||
})
|
||||
} else {
|
||||
var marketplace = Item.create({
|
||||
name: req.body.name,
|
||||
UserId: user.id,
|
||||
sourceFile: req.file.filename,
|
||||
previewFile: img4,
|
||||
limited: false,
|
||||
salePrice: req.body.onSalePrice,
|
||||
saleEnabled: req.body.onSale,
|
||||
price: req.body.price,
|
||||
quantityAllowed: 0,
|
||||
approved: false,
|
||||
ItemCategoryId: findCategory.id,
|
||||
description: req.body.description
|
||||
})
|
||||
}
|
||||
if(marketplace.ItemCategoryId === 0) {
|
||||
var type = "hat"
|
||||
} else if(marketplace.ItemCategoryId === 1) {
|
||||
|
|
|
@ -186,7 +186,7 @@ router.get('/getAll', auth, async(req, res, next) => {
|
|||
res.status(200)
|
||||
res.json({success: false})
|
||||
}
|
||||
let checkIfSent = await Relationship.findAll({
|
||||
let checkIfSent = await Relationship.findAndCountAll({
|
||||
where: {friend1Id: user.id},
|
||||
include: [{ model: User, as: 'friend1', attributes: ['username', 'createdAt', 'id', 'color', 'picture', 'locked', 'admin', 'booster', 'executive', 'bot'] }, { model: User, as: 'friend2', attributes: ['username', 'createdAt', 'id', 'color', 'picture', 'locked', 'admin', 'booster', 'executive', 'bot'] } ]
|
||||
})
|
||||
|
@ -200,4 +200,28 @@ router.get('/getAll', auth, async(req, res, next) => {
|
|||
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
router.get('/getAllPendingCanAccept', auth, async(req, res, next) => {
|
||||
try {
|
||||
let queryObj = {
|
||||
where: {username: req.userData.username}
|
||||
}
|
||||
let user = await User.findOne(queryObj)
|
||||
if (!user) {
|
||||
res.status(200)
|
||||
res.json({success: false})
|
||||
}
|
||||
let checkIfSent = await Relationship.findAndCountAll({
|
||||
where: {friend1Id: user.id, type: 'pendingCanAccept'},
|
||||
include: [{ model: User, as: 'friend1', attributes: ['username', 'createdAt', 'id', 'color', 'picture', 'locked', 'admin', 'booster', 'executive', 'bot'] }, { model: User, as: 'friend2', attributes: ['username', 'createdAt', 'id', 'color', 'picture', 'locked', 'admin', 'booster', 'executive', 'bot'] } ]
|
||||
})
|
||||
if (checkIfSent) {
|
||||
res.status(200)
|
||||
res.json(checkIfSent)
|
||||
} else {
|
||||
res.status(200)
|
||||
res.json({})
|
||||
}
|
||||
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
module.exports = router
|
||||
|
|
Loading…
Reference in a new issue