:" has set __"+req.body.item_name+"__ to "+req.body.obtained+" / "+req.body.required)+"\n\n[Sig Planner - Sig crafts all the things](http://projectdivar.com:3001)",
returndb.query("insert into audit_log(username,obtained,required,item_name,operation,date,previous_amt) values($1,$2,$3,$4,$5,$6,$7)",[req.body.username,req.body.obtained,req.body.required,req.body.item_name,req.body.operation==="FINISH"&&req.body.finalcraft===true?"FINISH_CRAFT":req.body.operation,req.body.last_modified,req.body.previous_amt])
db.query('insert into crafting_list(itemid,name,obtained,required,icon) values($1,$2,$3,$4,$5)',[req.body.itemid,req.body.name,req.body.obtained,req.body.required,req.body.icon])
.then((data)=>{
res.status(200).send("Yay!")
})
.catch((err)=>{
res.status(500).send(err.message)
})
}else{
db.query('update crafting_list set required=$1 where itemid=$2',[Number(data.rows[0].required)+Number(req.body.required),req.body.itemid])
awaitdb.query('select * from crafting_list where itemid=$1',[req.body.itemid])
.then((data)=>{
if(data.rows.length>0){
db.query('update crafting_list set obtained=$1 where itemid=$2',[Math.min(data.rows[0].required,Number(data.rows[0].obtained)+Number(req.body.obtained)),req.body.itemid])
name:"Issue #"+req.body.number+" opened by "+req.body.issue.user.username,
icon_url:req.body.issue.user.avatar_url
},
color:11731199,
description:"**"+req.body.issue.title+":**\n\n"+req.body.issue.body+"\n\n[Link to Issue]("+req.body.issue.html_url+")",
}]
})
}break;
case"reopened":{
axios.post(process.env.GITEA_WEBHOOK,{embeds:[{
author:{
name:"Issue #"+req.body.number+" re-opened by "+req.body.issue.user.username,
icon_url:req.body.issue.user.avatar_url
},
color:13789695,
description:"**"+req.body.issue.title+":**\n\n"+req.body.issue.body+"\n\n[Link to Issue]("+req.body.issue.html_url+")",
}]
})
}break;
case"assigned":{
varassignedList=""
for(assigneeofreq.body.issue.assignees){
if(assignedList.length==0){
assignedList+=assignee.username
}else{
assignedList+=","+assignee.username
}
}
axios.post(process.env.GITEA_WEBHOOK,{embeds:[{
author:{
name:"Assigned users to Issue #"+req.body.number,
icon_url:req.body.issue.user.avatar_url
},
color:50363,
description:"Assigned **"+assignedList+"** to Issue **"+req.body.issue.title+"**\n\n[Link to Issue]("+req.body.issue.html_url+")",
}]
})
}break;
case"label_updated":{
varlabelsList=""
for(labelofreq.body.issue.labels){
if(labelsList.length==0){
labelsList+="- **"+label.name+"**"
}else{
labelsList+="\n- **"+label.name+"**"
}
}
axios.post(process.env.GITEA_WEBHOOK,{embeds:[{
author:{
name:"Assigned labels to Issue #"+req.body.number,
icon_url:req.body.issue.user.avatar_url
},
color:365568,
description:"Labels set for Issue **"+req.body.issue.title+"**:\n"+labelsList+"\n\n[Link to Issue]("+req.body.issue.html_url+")",
}]
})
}break;
case"created":{
axios.post(process.env.GITEA_WEBHOOK,{embeds:[{
author:{
name:"Comment posted on Issue #"+req.body.issue.number,
icon_url:req.body.comment.user.avatar_url
},
color:11731199,
description:"__**"+req.body.issue.title+"**__\nCommented by **"+req.body.comment.user.username+":**\n"+req.body.comment.body+"\n\n[Link to Comment]("+req.body.comment.html_url+")",
}]
})
}break;
case"edited":{
axios.post(process.env.GITEA_WEBHOOK,{embeds:[{
author:{
name:"Comment edited on Issue #"+req.body.issue.number,
icon_url:req.body.comment.user.avatar_url
},
color:11731199,
description:"__**"+req.body.issue.title+"**__\nCommented by **"+req.body.comment.user.username+":**\n"+req.body.comment.body+"\n\n[Link to Comment]("+req.body.comment.html_url+")",
}]
})
}break;
case"deleted":{
axios.post(process.env.GITEA_WEBHOOK,{embeds:[{
author:{
name:"Comment deleted on Issue #"+req.body.issue.number,
icon_url:req.body.comment.user.avatar_url
},
color:11731199,
description:"__**"+req.body.issue.title+"**__\nCommented by **"+req.body.comment.user.username+":**\n~~"+req.body.comment.body+"~~\n\n[Link to Comment]("+req.body.comment.html_url+")",
}]
})
}break;
case"closed":{
axios.post(process.env.GITEA_WEBHOOK,{embeds:[{
author:{
name:"Issue #"+req.body.number+" closed by "+req.body.issue.user.username,
icon_url:req.body.issue.user.avatar_url
},
color:9502805,
description:"**"+req.body.issue.title+":**\n\n"+req.body.issue.body+"\n\n[Link to Issue]("+req.body.issue.html_url+")",
description:"**"+req.body.username+"** "+(req.body.operation==="FINISH"?" has finished "+(req.body.finalcraft===true?"crafting ":"collecting ")+req.body.required+" __"+req.body.item_name+"__!":
req.body.operation==="INCREASE"?" has collected "+req.body.obtained+" / "+req.body.required+" __"+req.body.item_name+"__ (+"+(req.body.obtained-req.body.previous_amt)+")"
:" has set __"+req.body.item_name+"__ to "+req.body.obtained+" / "+req.body.required)+"\n\n[Sig Planner - Sig crafts all the things](http://projectdivar.com:3001)",