add config.UseServerTime to make time tag overwrite opt-in. It will still be in tags

This commit is contained in:
2020-11-29 18:12:02 +01:00
parent 1372669042
commit 470acda045
2 changed files with 11 additions and 5 deletions
+8 -5
View File
@@ -852,11 +852,14 @@ func (client *Client) handleSendLoop() {
func (client *Client) handleEvent(event *Event) {
sentCapEnd := false
// IRCv3 `server-time`
if timeTag, ok := event.Tags["time"]; ok {
serverTime, err := time.Parse(time.RFC3339Nano, timeTag)
if err == nil && serverTime.Year() > 2000 {
event.Time = serverTime
// Only use IRCv3 `server-time` to overwrite when requested. Frontends/dependents can still
// get this information.
if client.config.UseServerTime {
if timeTag, ok := event.Tags["time"]; ok {
serverTime, err := time.Parse(time.RFC3339Nano, timeTag)
if err == nil && serverTime.Year() > 2000 {
event.Time = serverTime
}
}
}
+3
View File
@@ -37,6 +37,9 @@ type Config struct {
// Auto-join on invite (bad idea).
AutoJoinInvites bool `json:"autoJoinInvites"`
// Whether to use the server time tag to overwrite event time.
UseServerTime bool `json:"useServerTime"`
// Use SASL authorization if supported.
SASL *SASLConfig `json:"sasl"`
}