Feedback rating

This commit is contained in:
rxdn 2021-07-28 14:51:37 +01:00
parent 9be5f7154d
commit a8dfbb413e
8 changed files with 41 additions and 20 deletions

View File

@ -18,6 +18,7 @@ type Settings struct {
PingEveryone bool `json:"ping_everyone"`
UsersCanClose bool `json:"users_can_close"`
CloseConfirmation bool `json:"close_confirmation"`
FeedbackEnabled bool `json:"feedback_enabled"`
}
func GetSettingsHandler(ctx *gin.Context) {
@ -93,6 +94,12 @@ func GetSettingsHandler(ctx *gin.Context) {
return
})
// close confirmation
group.Go(func() (err error) {
settings.FeedbackEnabled, err = dbclient.Client.FeedbackEnabled.Get(guildId)
return
})
if err := group.Wait(); err != nil {
ctx.AbortWithStatusJSON(500, gin.H{
"success": false,

View File

@ -23,7 +23,7 @@ func UpdateSettingsHandler(ctx *gin.Context) {
// Get a list of all channel IDs
channels := cache.Instance.GetGuildChannels(guildId)
// Get prefix
// TODO: Errors
validPrefix := settings.updatePrefix(guildId)
validWelcomeMessage := settings.updateWelcomeMessage(guildId)
validTicketLimit := settings.updateTicketLimit(guildId)
@ -33,6 +33,7 @@ func UpdateSettingsHandler(ctx *gin.Context) {
settings.updatePingEveryone(guildId)
settings.updateUsersCanClose(guildId)
settings.updateCloseConfirmation(guildId)
settings.updateFeedbackEnabled(guildId)
ctx.JSON(200, gin.H{
"prefix": validPrefix,
@ -135,3 +136,8 @@ func (s *Settings) updateUsersCanClose(guildId uint64) {
func (s *Settings) updateCloseConfirmation(guildId uint64) {
go dbclient.Client.CloseConfirmation.Set(guildId, s.CloseConfirmation)
}
func (s *Settings) updateFeedbackEnabled(guildId uint64) {
go dbclient.Client.FeedbackEnabled.Set(guildId, s.FeedbackEnabled)
}

View File

@ -51,12 +51,17 @@ func main() {
messagequeue.Client = messagequeue.NewRedisClient()
go ListenChat(messagequeue.Client)
if !config.Conf.Debug {
rpc.PremiumClient = premium.NewPremiumLookupClient(
premium.NewPatreonClient(config.Conf.Bot.PremiumLookupProxyUrl, config.Conf.Bot.PremiumLookupProxyKey),
messagequeue.Client.Client,
cache.Instance.PgCache,
database.Client,
)
} else {
c := premium.NewMockLookupClient(premium.Whitelabel, premium.SourcePatreon)
rpc.PremiumClient = &c
}
http.StartServer()
}

View File

@ -12,6 +12,7 @@ type (
Config struct {
Admins []uint64
ForceWhitelabel []uint64
Debug bool
Server Server
Oauth Oauth
Database Database
@ -122,6 +123,7 @@ func fromEnvvar() {
Conf = Config{
Admins: admins,
ForceWhitelabel: forcedWhitelabel,
Debug: os.Getenv("DEBUG") != "",
Server: Server{
Host: os.Getenv("SERVER_ADDR"),
BaseUrl: os.Getenv("BASE_URL"),

View File

@ -12,7 +12,8 @@
<Checkbox label="ticket close confirmation" col4=true bind:value={data.close_confirmation}/>
</div>
<div class="row">
<Textarea label="welcome message" placeholder="Thanks for opening a ticket!" col1=true bind:value={data.welcome_message} />
<Textarea label="welcome message" placeholder="Thanks for opening a ticket!" col1=true
bind:value={data.welcome_message}/>
</div>
<div class="row">
<ChannelDropdown label="Archive Channel" col2=true channels={channels} bind:value={data.archive_channel}/>
@ -20,8 +21,9 @@
</div>
<div class="row">
<NamingScheme col4=true bind:value={data.naming_scheme}/>
<Checkbox label="Ask Users To Rate Service" col4=true bind:value={data.feedback_enabled}/>
</div>
<div class="row">
<div class="row" style="justify-content: flex-start">
<div class="col-1">
<Button icon="fas fa-paper-plane" fullWidth=true>Submit</Button>
</div>
@ -32,9 +34,6 @@
<script>
import ChannelDropdown from "../ChannelDropdown.svelte";
export let guildId;
import Card from "../Card.svelte";
import Input from "../form/Input.svelte";
import Number from "../form/Number.svelte";
@ -49,6 +48,8 @@
import Button from "../Button.svelte";
import NamingScheme from "../NamingScheme.svelte";
export let guildId;
setDefaultHeaders();
let channels = [];

View File

@ -1,4 +1,4 @@
export const API_URL = env.API_URL || "http://172.24.138.236:3000"
export const API_URL = env.API_URL || "http://192.168.90.213:3000"
export const PLACEHOLDER_DOCS_URL = "https://docs.ticketsbot.net/setup/placeholders.html"
export const OAUTH = {

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v0.3.1
github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb
github.com/TicketsBot/common v0.0.0-20210727134627-35eb7ed03a44
github.com/TicketsBot/database v0.0.0-20210725125137-5540e9ff7484
github.com/TicketsBot/database v0.0.0-20210728122440-a0cf03a651c8
github.com/TicketsBot/worker v0.0.0-20210727130432-3df3cd1246a3
github.com/apex/log v1.1.2
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect

View File

@ -2,4 +2,4 @@ package rpc
import "github.com/TicketsBot/common/premium"
var PremiumClient *premium.PremiumLookupClient
var PremiumClient premium.IPremiumLookupClient