mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
parent
4e49a25ba6
commit
44ed0b7a38
@ -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")
|
||||||
accountName = client.AccountName()
|
if !isOper {
|
||||||
if !(server.Config().History.Retention.AllowIndividualDelete && accountName != "*") {
|
if server.Config().History.Retention.AllowIndividualDelete {
|
||||||
service.Notice(rb, client.t("Insufficient privileges"))
|
channel := server.channels.Get(target)
|
||||||
return
|
if channel != nil && channel.ClientIsAtLeast(client, modes.Operator) {
|
||||||
|
isChanop = true
|
||||||
|
} else {
|
||||||
|
accountName = client.AccountName()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !isOper && !isChanop && accountName == "*" {
|
||||||
|
service.Notice(rb, client.t("Insufficient privileges"))
|
||||||
|
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"))
|
||||||
|
Loading…
Reference in New Issue
Block a user