autoclose on user leave
This commit is contained in:
parent
94289451b1
commit
d28c4df230
@ -18,7 +18,7 @@ func PostAutoClose(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if settings.Enabled && (settings.SinceLastMessage == nil || settings.SinceOpenWithNoResponse == nil) {
|
if settings.Enabled && (settings.SinceLastMessage == nil || settings.SinceOpenWithNoResponse == nil || settings.OnUserLeave == nil) {
|
||||||
ctx.AbortWithStatusJSON(400, gin.H{
|
ctx.AbortWithStatusJSON(400, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"error": "No time period provided",
|
"error": "No time period provided",
|
||||||
@ -34,6 +34,12 @@ func PostAutoClose(ctx *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !settings.Enabled {
|
||||||
|
settings.SinceLastMessage = nil
|
||||||
|
settings.SinceOpenWithNoResponse = nil
|
||||||
|
settings.OnUserLeave = nil
|
||||||
|
}
|
||||||
|
|
||||||
if err := dbclient.Client.AutoClose.Set(guildId, settings); err != nil {
|
if err := dbclient.Client.AutoClose.Set(guildId, settings); err != nil {
|
||||||
ctx.AbortWithStatusJSON(500, gin.H{
|
ctx.AbortWithStatusJSON(500, gin.H{
|
||||||
"success": false,
|
"success": false,
|
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
|||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/TicketsBot/archiverclient v0.0.0-20200425115930-0ca198cc8306
|
github.com/TicketsBot/archiverclient v0.0.0-20200425115930-0ca198cc8306
|
||||||
github.com/TicketsBot/common v0.0.0-20200529141045-7426ad13f1a4
|
github.com/TicketsBot/common v0.0.0-20200529141045-7426ad13f1a4
|
||||||
github.com/TicketsBot/database v0.0.0-20200604215726-514be849d31c
|
github.com/TicketsBot/database v0.0.0-20200606205929-6851b2444a67
|
||||||
github.com/apex/log v1.1.2
|
github.com/apex/log v1.1.2
|
||||||
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||||
|
@ -189,7 +189,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form onsubmit="updateAutoCloseSettings(); return false;">
|
<form onsubmit="updateAutoCloseSettings(); return false;">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-2 pr-1">
|
<div class="col-md-1 pr-1">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Enabled</label>
|
<label>Enabled</label>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
@ -197,7 +197,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col-md-2 pr-1">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Close on user leave</label>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="enabled" value="on" id="autoclose_on_user_leave" style="width:30px;height:30px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Time since open with no message</label>
|
<label>Time since open with no message</label>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -222,7 +230,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-5">
|
<div class="col-md-4">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Time since last message</label>
|
<label>Time since last message</label>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -393,11 +401,12 @@
|
|||||||
return [days, hours, minutes];
|
return [days, hours, minutes];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadAutoClaimSettings() {
|
async function loadAutoCloseSettings() {
|
||||||
const res = await axios.get('/api/{{.guildId}}/autoclose');
|
const res = await axios.get('/api/{{.guildId}}/autoclose');
|
||||||
const settings = res.data;
|
const settings = res.data;
|
||||||
|
|
||||||
document.getElementById('autoclose_enabled').checked = settings.enabled;
|
document.getElementById('autoclose_enabled').checked = settings.enabled;
|
||||||
|
document.getElementById('autoclose_on_user_leave').checked = settings.on_user_leave;
|
||||||
|
|
||||||
const sinceOpen = fromNanoSeconds(settings.since_open_with_no_response);
|
const sinceOpen = fromNanoSeconds(settings.since_open_with_no_response);
|
||||||
document.getElementById('sinceopen_days').value = sinceOpen[0];
|
document.getElementById('sinceopen_days').value = sinceOpen[0];
|
||||||
@ -417,6 +426,7 @@
|
|||||||
async function updateAutoCloseSettings() {
|
async function updateAutoCloseSettings() {
|
||||||
const data = {
|
const data = {
|
||||||
enabled: document.getElementById('autoclose_enabled').checked,
|
enabled: document.getElementById('autoclose_enabled').checked,
|
||||||
|
on_user_leave: document.getElementById('autoclose_on_user_leave').checked,
|
||||||
since_open_with_no_response: toNanoSeconds(document.getElementById('sinceopen_days').value, document.getElementById('sinceopen_hours').value, document.getElementById('sinceopen_minutes').value),
|
since_open_with_no_response: toNanoSeconds(document.getElementById('sinceopen_days').value, document.getElementById('sinceopen_hours').value, document.getElementById('sinceopen_minutes').value),
|
||||||
since_last_message: toNanoSeconds(document.getElementById('sincelast_days').value, document.getElementById('sincelast_hours').value, document.getElementById('sincelast_minutes').value),
|
since_last_message: toNanoSeconds(document.getElementById('sincelast_days').value, document.getElementById('sincelast_hours').value, document.getElementById('sincelast_minutes').value),
|
||||||
};
|
};
|
||||||
@ -430,7 +440,7 @@
|
|||||||
showToast('Success', 'Auto close settings updated');
|
showToast('Success', 'Auto close settings updated');
|
||||||
}
|
}
|
||||||
|
|
||||||
loadAutoClaimSettings();
|
loadAutoCloseSettings();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user