mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
Merge pull request #1591 from slingamn/grabbag
some small fixes/enhancements
This commit is contained in:
commit
507d53c507
@ -1324,6 +1324,12 @@ func (channel *Channel) isMuted(client *Client) bool {
|
|||||||
return muteRe.MatchString(nuh) && !channel.lists[modes.ExceptMask].MatchMute(nuh)
|
return muteRe.MatchString(nuh) && !channel.lists[modes.ExceptMask].MatchMute(nuh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (channel *Channel) relayNickMuted(relayNick string) bool {
|
||||||
|
relayNUH := fmt.Sprintf("%s!*@*", relayNick)
|
||||||
|
return channel.lists[modes.BanMask].MatchMute(relayNUH) &&
|
||||||
|
!channel.lists[modes.ExceptMask].MatchMute(relayNUH)
|
||||||
|
}
|
||||||
|
|
||||||
func msgCommandToHistType(command string) (history.ItemType, error) {
|
func msgCommandToHistType(command string) (history.ItemType, error) {
|
||||||
switch command {
|
switch command {
|
||||||
case "PRIVMSG":
|
case "PRIVMSG":
|
||||||
|
@ -579,8 +579,13 @@ func csTransferHandler(service *ircService, server *Server, client *Client, comm
|
|||||||
service.Notice(rb, fmt.Sprintf(client.t("Cancelled pending transfer of channel %s"), chname))
|
service.Notice(rb, fmt.Sprintf(client.t("Cancelled pending transfer of channel %s"), chname))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
switch err {
|
||||||
|
case errChannelNotOwnedByAccount:
|
||||||
|
service.Notice(rb, client.t("You don't own that channel"))
|
||||||
|
default:
|
||||||
service.Notice(rb, client.t("Could not transfer channel"))
|
service.Notice(rb, client.t("Could not transfer channel"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendTransferPendingNotice(service *ircService, server *Server, account, chname string) {
|
func sendTransferPendingNotice(service *ircService, server *Server, account, chname string) {
|
||||||
|
@ -2647,6 +2647,10 @@ func relaymsgHandler(server *Server, client *Client, msg ircmsg.Message, rb *Res
|
|||||||
rb.Add(nil, server.name, "FAIL", "RELAYMSG", "INVALID_NICK", fmt.Sprintf(client.t("Relayed nicknames MUST contain a relaymsg separator from this set: %s"), config.Server.Relaymsg.Separators))
|
rb.Add(nil, server.name, "FAIL", "RELAYMSG", "INVALID_NICK", fmt.Sprintf(client.t("Relayed nicknames MUST contain a relaymsg separator from this set: %s"), config.Server.Relaymsg.Separators))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if channel.relayNickMuted(nick) {
|
||||||
|
rb.Add(nil, server.name, "FAIL", "RELAYMSG", "BANNED", fmt.Sprintf(client.t("%s is banned from relaying to the channel"), nick))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
channel.AddHistoryItem(history.Item{
|
channel.AddHistoryItem(history.Item{
|
||||||
Type: history.Privmsg,
|
Type: history.Privmsg,
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/oragono/oragono/irc/history"
|
"github.com/oragono/oragono/irc/history"
|
||||||
|
"github.com/oragono/oragono/irc/modes"
|
||||||
"github.com/oragono/oragono/irc/utils"
|
"github.com/oragono/oragono/irc/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -102,21 +103,31 @@ func histservDeleteHandler(service *ircService, server *Server, client *Client,
|
|||||||
target, msgid = params[0], params[1]
|
target, msgid = params[0], params[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// operators can delete; if individual delete is allowed, a chanop or
|
||||||
|
// the message author can delete
|
||||||
accountName := "*"
|
accountName := "*"
|
||||||
hasPrivs := client.HasRoleCapabs("history")
|
isChanop := false
|
||||||
if !hasPrivs {
|
isOper := client.HasRoleCapabs("history")
|
||||||
|
if !isOper {
|
||||||
|
if server.Config().History.Retention.AllowIndividualDelete {
|
||||||
|
channel := server.channels.Get(target)
|
||||||
|
if channel != nil && channel.ClientIsAtLeast(client, modes.Operator) {
|
||||||
|
isChanop = true
|
||||||
|
} else {
|
||||||
accountName = client.AccountName()
|
accountName = client.AccountName()
|
||||||
if !(server.Config().History.Retention.AllowIndividualDelete && accountName != "*") {
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !isOper && !isChanop && accountName == "*" {
|
||||||
service.Notice(rb, client.t("Insufficient privileges"))
|
service.Notice(rb, client.t("Insufficient privileges"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
err := server.DeleteMessage(target, msgid, accountName)
|
err := server.DeleteMessage(target, msgid, accountName)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
service.Notice(rb, client.t("Successfully deleted message"))
|
service.Notice(rb, client.t("Successfully deleted message"))
|
||||||
} else {
|
} else {
|
||||||
if hasPrivs {
|
if isOper {
|
||||||
service.Notice(rb, fmt.Sprintf(client.t("Error deleting message: %v"), err))
|
service.Notice(rb, fmt.Sprintf(client.t("Error deleting message: %v"), err))
|
||||||
} else {
|
} else {
|
||||||
service.Notice(rb, client.t("Could not delete message"))
|
service.Notice(rb, client.t("Could not delete message"))
|
||||||
|
@ -425,7 +425,7 @@ func displaySetting(service *ircService, settingName string, settings AccountSet
|
|||||||
case "always-on":
|
case "always-on":
|
||||||
stored := settings.AlwaysOn
|
stored := settings.AlwaysOn
|
||||||
actual := persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, stored)
|
actual := persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, stored)
|
||||||
service.Notice(rb, fmt.Sprintf(client.t("Your stored always-on setting is: %s"), persistentStatusToString(stored)))
|
service.Notice(rb, fmt.Sprintf(client.t("Your stored always-on setting is: %s"), userPersistentStatusToString(stored)))
|
||||||
if actual {
|
if actual {
|
||||||
service.Notice(rb, client.t("Given current server settings, your client is always-on"))
|
service.Notice(rb, client.t("Given current server settings, your client is always-on"))
|
||||||
} else {
|
} else {
|
||||||
@ -447,7 +447,7 @@ func displaySetting(service *ircService, settingName string, settings AccountSet
|
|||||||
stored := settings.AutoAway
|
stored := settings.AutoAway
|
||||||
alwaysOn := persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, settings.AlwaysOn)
|
alwaysOn := persistenceEnabled(config.Accounts.Multiclient.AlwaysOn, settings.AlwaysOn)
|
||||||
actual := persistenceEnabled(config.Accounts.Multiclient.AutoAway, settings.AutoAway)
|
actual := persistenceEnabled(config.Accounts.Multiclient.AutoAway, settings.AutoAway)
|
||||||
service.Notice(rb, fmt.Sprintf(client.t("Your stored auto-away setting is: %s"), persistentStatusToString(stored)))
|
service.Notice(rb, fmt.Sprintf(client.t("Your stored auto-away setting is: %s"), userPersistentStatusToString(stored)))
|
||||||
if actual && alwaysOn {
|
if actual && alwaysOn {
|
||||||
service.Notice(rb, client.t("Given current server settings, auto-away is enabled for your client"))
|
service.Notice(rb, client.t("Given current server settings, auto-away is enabled for your client"))
|
||||||
} else if actual && !alwaysOn {
|
} else if actual && !alwaysOn {
|
||||||
@ -465,6 +465,15 @@ func displaySetting(service *ircService, settingName string, settings AccountSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func userPersistentStatusToString(status PersistentStatus) string {
|
||||||
|
// #1544: "mandatory" as a user setting should display as "enabled"
|
||||||
|
result := persistentStatusToString(status)
|
||||||
|
if result == "mandatory" {
|
||||||
|
result = "enabled"
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func nsSetHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
func nsSetHandler(service *ircService, server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
||||||
var account string
|
var account string
|
||||||
if command == "saset" {
|
if command == "saset" {
|
||||||
|
@ -153,10 +153,8 @@ func (server *Server) Run() {
|
|||||||
return
|
return
|
||||||
|
|
||||||
case <-server.rehashSignal:
|
case <-server.rehashSignal:
|
||||||
go func() {
|
|
||||||
server.logger.Info("server", "Rehashing due to SIGHUP")
|
server.logger.Info("server", "Rehashing due to SIGHUP")
|
||||||
server.rehash()
|
go server.rehash()
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -520,14 +518,24 @@ func (client *Client) getWhoisOf(target *Client, hasPrivs bool, rb *ResponseBuff
|
|||||||
|
|
||||||
// rehash reloads the config and applies the changes from the config file.
|
// rehash reloads the config and applies the changes from the config file.
|
||||||
func (server *Server) rehash() error {
|
func (server *Server) rehash() error {
|
||||||
|
// #1570; this needs its own panic handling because it can be invoked via SIGHUP
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
if server.Config().Debug.recoverFromErrors {
|
||||||
|
server.logger.Error("internal",
|
||||||
|
fmt.Sprintf("Panic during rehash: %v\n%s", r, debug.Stack()))
|
||||||
|
} else {
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
server.logger.Info("server", "Attempting rehash")
|
server.logger.Info("server", "Attempting rehash")
|
||||||
|
|
||||||
// only let one REHASH go on at a time
|
// only let one REHASH go on at a time
|
||||||
server.rehashMutex.Lock()
|
server.rehashMutex.Lock()
|
||||||
defer server.rehashMutex.Unlock()
|
defer server.rehashMutex.Unlock()
|
||||||
|
|
||||||
server.logger.Debug("server", "Got rehash lock")
|
|
||||||
|
|
||||||
config, err := LoadConfig(server.configFilename)
|
config, err := LoadConfig(server.configFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
server.logger.Error("server", "failed to load config file", err.Error())
|
server.logger.Error("server", "failed to load config file", err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user