|
@@ -13,6 +13,7 @@ import (
|
13
|
13
|
"time"
|
14
|
14
|
|
15
|
15
|
"github.com/oragono/oragono/irc/history"
|
|
16
|
+ "github.com/oragono/oragono/irc/modes"
|
16
|
17
|
"github.com/oragono/oragono/irc/utils"
|
17
|
18
|
)
|
18
|
19
|
|
|
@@ -102,21 +103,31 @@ func histservDeleteHandler(service *ircService, server *Server, client *Client,
|
102
|
103
|
target, msgid = params[0], params[1]
|
103
|
104
|
}
|
104
|
105
|
|
|
106
|
+ // operators can delete; if individual delete is allowed, a chanop or
|
|
107
|
+ // the message author can delete
|
105
|
108
|
accountName := "*"
|
106
|
|
- hasPrivs := client.HasRoleCapabs("history")
|
107
|
|
- if !hasPrivs {
|
108
|
|
- accountName = client.AccountName()
|
109
|
|
- if !(server.Config().History.Retention.AllowIndividualDelete && accountName != "*") {
|
110
|
|
- service.Notice(rb, client.t("Insufficient privileges"))
|
111
|
|
- return
|
|
109
|
+ isChanop := false
|
|
110
|
+ isOper := client.HasRoleCapabs("history")
|
|
111
|
+ if !isOper {
|
|
112
|
+ if server.Config().History.Retention.AllowIndividualDelete {
|
|
113
|
+ channel := server.channels.Get(target)
|
|
114
|
+ if channel != nil && channel.ClientIsAtLeast(client, modes.Operator) {
|
|
115
|
+ isChanop = true
|
|
116
|
+ } else {
|
|
117
|
+ accountName = client.AccountName()
|
|
118
|
+ }
|
112
|
119
|
}
|
113
|
120
|
}
|
|
121
|
+ if !isOper && !isChanop && accountName == "*" {
|
|
122
|
+ service.Notice(rb, client.t("Insufficient privileges"))
|
|
123
|
+ return
|
|
124
|
+ }
|
114
|
125
|
|
115
|
126
|
err := server.DeleteMessage(target, msgid, accountName)
|
116
|
127
|
if err == nil {
|
117
|
128
|
service.Notice(rb, client.t("Successfully deleted message"))
|
118
|
129
|
} else {
|
119
|
|
- if hasPrivs {
|
|
130
|
+ if isOper {
|
120
|
131
|
service.Notice(rb, fmt.Sprintf(client.t("Error deleting message: %v"), err))
|
121
|
132
|
} else {
|
122
|
133
|
service.Notice(rb, client.t("Could not delete message"))
|