downstream: Enable handling READ when upstream is disconnected
Previously, when we sent READ for an upstream which was disconnected, we would fail with an error. This is because we called unmarshalEntity, which checked that the upstream was in the connected status. But we don't need to be connected to update the READ timestamp, this is a purely offline (wrt the upstream) operation. This simply switches the call from unmarshalEntity to unmarshalEntityNetwork to fix the issue.
This commit is contained in:
parent
fdf9727600
commit
9376c8885c
@ -2812,13 +2812,13 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
uc, entity, err := dc.unmarshalEntity(target)
|
network, entity, err := dc.unmarshalEntityNetwork(target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
entityCM := uc.network.casemap(entity)
|
entityCM := network.casemap(entity)
|
||||||
|
|
||||||
r, err := dc.srv.db.GetReadReceipt(ctx, uc.network.ID, entityCM)
|
r, err := dc.srv.db.GetReadReceipt(ctx, network.ID, entityCM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dc.logger.Printf("failed to get the read receipt for %q: %v", entity, err)
|
dc.logger.Printf("failed to get the read receipt for %q: %v", entity, err)
|
||||||
return ircError{&irc.Message{
|
return ircError{&irc.Message{
|
||||||
@ -2855,7 +2855,7 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
|
|||||||
}
|
}
|
||||||
if r.Timestamp.Before(timestamp) {
|
if r.Timestamp.Before(timestamp) {
|
||||||
r.Timestamp = timestamp
|
r.Timestamp = timestamp
|
||||||
if err := dc.srv.db.StoreReadReceipt(ctx, uc.network.ID, r); err != nil {
|
if err := dc.srv.db.StoreReadReceipt(ctx, network.ID, r); err != nil {
|
||||||
dc.logger.Printf("failed to store receipt for %q: %v", entity, err)
|
dc.logger.Printf("failed to store receipt for %q: %v", entity, err)
|
||||||
return ircError{&irc.Message{
|
return ircError{&irc.Message{
|
||||||
Command: "FAIL",
|
Command: "FAIL",
|
||||||
@ -2870,12 +2870,12 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
|
|||||||
if !r.Timestamp.IsZero() {
|
if !r.Timestamp.IsZero() {
|
||||||
timestampStr = fmt.Sprintf("timestamp=%s", formatServerTime(r.Timestamp))
|
timestampStr = fmt.Sprintf("timestamp=%s", formatServerTime(r.Timestamp))
|
||||||
}
|
}
|
||||||
uc.forEachDownstream(func(d *downstreamConn) {
|
network.forEachDownstream(func(d *downstreamConn) {
|
||||||
if broadcast || dc.id == d.id {
|
if broadcast || dc.id == d.id {
|
||||||
d.SendMessage(&irc.Message{
|
d.SendMessage(&irc.Message{
|
||||||
Prefix: d.prefix(),
|
Prefix: d.prefix(),
|
||||||
Command: "READ",
|
Command: "READ",
|
||||||
Params: []string{d.marshalEntity(uc.network, entity), timestampStr},
|
Params: []string{d.marshalEntity(network, entity), timestampStr},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user