|
@@ -7,6 +7,8 @@ import (
|
7
|
7
|
"errors"
|
8
|
8
|
"fmt"
|
9
|
9
|
"regexp"
|
|
10
|
+
|
|
11
|
+ "github.com/oragono/oragono/irc/sno"
|
10
|
12
|
)
|
11
|
13
|
|
12
|
14
|
const hostservHelp = `HostServ lets you manage your vhost (i.e., the string displayed
|
|
@@ -216,6 +218,8 @@ func hsRequestHandler(server *Server, client *Client, command string, params []s
|
216
|
218
|
if err != nil {
|
217
|
219
|
if throttled, ok := err.(*vhostThrottleExceeded); ok {
|
218
|
220
|
hsNotice(rb, fmt.Sprintf(client.t("You must wait an additional %v before making another request"), throttled.timeRemaining))
|
|
221
|
+ } else if err == errVhostsForbidden {
|
|
222
|
+ hsNotice(rb, client.t("An administrator has denied you the ability to use vhosts"))
|
219
|
223
|
} else {
|
220
|
224
|
hsNotice(rb, client.t("An error occurred"))
|
221
|
225
|
}
|
|
@@ -223,7 +227,7 @@ func hsRequestHandler(server *Server, client *Client, command string, params []s
|
223
|
227
|
hsNotice(rb, client.t("Your vhost request will be reviewed by an administrator"))
|
224
|
228
|
chanMsg := fmt.Sprintf("Account %s requests vhost %s", accountName, vhost)
|
225
|
229
|
hsNotifyChannel(server, chanMsg)
|
226
|
|
- // TODO send admins a snomask of some kind
|
|
230
|
+ server.snomasks.Send(sno.LocalVhosts, chanMsg)
|
227
|
231
|
}
|
228
|
232
|
}
|
229
|
233
|
|
|
@@ -298,7 +302,7 @@ func hsSetHandler(server *Server, client *Client, command string, params []strin
|
298
|
302
|
}
|
299
|
303
|
// else: command == "del", vhost == ""
|
300
|
304
|
|
301
|
|
- _, err := server.accounts.VHostSet(user, vhost, 0)
|
|
305
|
+ _, err := server.accounts.VHostSet(user, vhost)
|
302
|
306
|
if err != nil {
|
303
|
307
|
hsNotice(rb, client.t("An error occurred"))
|
304
|
308
|
} else if vhost != "" {
|
|
@@ -326,6 +330,7 @@ func hsApproveHandler(server *Server, client *Client, command string, params []s
|
326
|
330
|
hsNotice(rb, fmt.Sprintf(client.t("Successfully approved vhost request for %s"), user))
|
327
|
331
|
chanMsg := fmt.Sprintf("Oper %[1]s approved vhost %[2]s for account %[3]s", client.Nick(), vhostInfo.ApprovedVHost, user)
|
328
|
332
|
hsNotifyChannel(server, chanMsg)
|
|
333
|
+ server.snomasks.Send(sno.LocalVhosts, chanMsg)
|
329
|
334
|
for _, client := range server.accounts.AccountToClients(user) {
|
330
|
335
|
client.Notice(client.t("Your vhost request was approved by an administrator"))
|
331
|
336
|
}
|
|
@@ -346,6 +351,7 @@ func hsRejectHandler(server *Server, client *Client, command string, params []st
|
346
|
351
|
hsNotice(rb, fmt.Sprintf(client.t("Successfully rejected vhost request for %s"), user))
|
347
|
352
|
chanMsg := fmt.Sprintf("Oper %s rejected vhost %s for account %s, with the reason: %v", client.Nick(), vhostInfo.RejectedVHost, user, reason)
|
348
|
353
|
hsNotifyChannel(server, chanMsg)
|
|
354
|
+ server.snomasks.Send(sno.LocalVhosts, chanMsg)
|
349
|
355
|
for _, client := range server.accounts.AccountToClients(user) {
|
350
|
356
|
if reason == "" {
|
351
|
357
|
client.Notice("Your vhost request was rejected by an administrator")
|
|
@@ -404,16 +410,18 @@ func hsTakeHandler(server *Server, client *Client, command string, params []stri
|
404
|
410
|
return
|
405
|
411
|
}
|
406
|
412
|
|
407
|
|
- _, err := server.accounts.VHostSet(client.Account(), vhost, config.Accounts.VHosts.UserRequests.Cooldown)
|
|
413
|
+ account := client.Account()
|
|
414
|
+ _, err := server.accounts.VHostTake(account, vhost, config.Accounts.VHosts.UserRequests.Cooldown)
|
408
|
415
|
if err != nil {
|
409
|
416
|
if throttled, ok := err.(*vhostThrottleExceeded); ok {
|
410
|
417
|
hsNotice(rb, fmt.Sprintf(client.t("You must wait an additional %v before taking a vhost"), throttled.timeRemaining))
|
|
418
|
+ } else if err == errVhostsForbidden {
|
|
419
|
+ hsNotice(rb, client.t("An administrator has denied you the ability to use vhosts"))
|
411
|
420
|
} else {
|
412
|
421
|
hsNotice(rb, client.t("An error occurred"))
|
413
|
422
|
}
|
414
|
|
- } else if vhost != "" {
|
415
|
|
- hsNotice(rb, client.t("Successfully set vhost"))
|
416
|
423
|
} else {
|
417
|
|
- hsNotice(rb, client.t("Successfully cleared vhost"))
|
|
424
|
+ hsNotice(rb, client.t("Successfully set vhost"))
|
|
425
|
+ server.snomasks.Send(sno.LocalVhosts, fmt.Sprintf("Client %s (account %s) took vhost %s", client.Nick(), account, vhost))
|
418
|
426
|
}
|
419
|
427
|
}
|