|
@@ -13,6 +13,7 @@ import (
|
13
|
13
|
"time"
|
14
|
14
|
|
15
|
15
|
"github.com/oragono/oragono/irc/history"
|
|
16
|
+ "github.com/oragono/oragono/irc/utils"
|
16
|
17
|
)
|
17
|
18
|
|
18
|
19
|
const (
|
|
@@ -57,8 +58,8 @@ be necessary to locate the message.`,
|
57
|
58
|
handler: histservExportHandler,
|
58
|
59
|
help: `Syntax: $bEXPORT <account>$b
|
59
|
60
|
|
60
|
|
-EXPORT exports all messages sent by an account as JSON. This can be used
|
61
|
|
-for regulatory compliance, e.g., article 15 of the GDPR.`,
|
|
61
|
+EXPORT exports all messages sent by an account as JSON. This can be used for
|
|
62
|
+regulatory compliance.`,
|
62
|
63
|
helpShort: `$bEXPORT$b exports all messages sent by an account as JSON.`,
|
63
|
64
|
enabled: historyComplianceEnabled,
|
64
|
65
|
capabs: []string{"history"},
|
|
@@ -137,19 +138,20 @@ func histservExportHandler(server *Server, client *Client, command string, param
|
137
|
138
|
}
|
138
|
139
|
|
139
|
140
|
config := server.Config()
|
140
|
|
- filename := fmt.Sprintf("%s@%s.json", cfAccount, time.Now().UTC().Format(IRCv3TimestampFormat))
|
|
141
|
+ // don't include the account name in the filename because of escaping concerns
|
|
142
|
+ filename := fmt.Sprintf("%s-%s.json", utils.GenerateSecretToken(), time.Now().UTC().Format(IRCv3TimestampFormat))
|
141
|
143
|
pathname := config.getOutputPath(filename)
|
142
|
144
|
outfile, err := os.Create(pathname)
|
143
|
145
|
if err != nil {
|
144
|
146
|
hsNotice(rb, fmt.Sprintf(client.t("Error opening export file: %v"), err))
|
145
|
147
|
} else {
|
146
|
|
- hsNotice(rb, fmt.Sprintf(client.t("Started exporting account data to file %s"), pathname))
|
|
148
|
+ hsNotice(rb, fmt.Sprintf(client.t("Started exporting data for account %s to file %s"), cfAccount, filename))
|
147
|
149
|
}
|
148
|
150
|
|
149
|
|
- go histservExportAndNotify(server, cfAccount, outfile, client.Nick())
|
|
151
|
+ go histservExportAndNotify(server, cfAccount, outfile, filename, client.Nick())
|
150
|
152
|
}
|
151
|
153
|
|
152
|
|
-func histservExportAndNotify(server *Server, cfAccount string, outfile *os.File, alertNick string) {
|
|
154
|
+func histservExportAndNotify(server *Server, cfAccount string, outfile *os.File, filename, alertNick string) {
|
153
|
155
|
defer func() {
|
154
|
156
|
if r := recover(); r != nil {
|
155
|
157
|
server.logger.Error("history",
|
|
@@ -165,7 +167,7 @@ func histservExportAndNotify(server *Server, cfAccount string, outfile *os.File,
|
165
|
167
|
|
166
|
168
|
client := server.clients.Get(alertNick)
|
167
|
169
|
if client != nil && client.HasRoleCapabs("history") {
|
168
|
|
- client.Send(nil, histServMask, "NOTICE", client.Nick(), fmt.Sprintf(client.t("Data export for %[1]s completed and written to %[2]s"), cfAccount, outfile.Name()))
|
|
170
|
+ client.Send(nil, histServMask, "NOTICE", client.Nick(), fmt.Sprintf(client.t("Data export for %[1]s completed and written to %[2]s"), cfAccount, filename))
|
169
|
171
|
}
|
170
|
172
|
}
|
171
|
173
|
|