mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 06:53:09 -06:00
fix history visibility boundary logic
This commit is contained in:
parent
5b8fb2cb23
commit
0c76e61e6b
|
|
@ -163,17 +163,23 @@ func ApplyHistoryVisibilityFilter(
|
||||||
// by setting the effective evVis to the least restrictive
|
// by setting the effective evVis to the least restrictive
|
||||||
// of the old vs new.
|
// of the old vs new.
|
||||||
// https://spec.matrix.org/v1.3/client-server-api/#server-behaviour-5
|
// https://spec.matrix.org/v1.3/client-server-api/#server-behaviour-5
|
||||||
if hisVis, err := ev.HistoryVisibility(); err == nil {
|
if ev.Type() == spec.MRoomHistoryVisibility {
|
||||||
prevHisVis := gjson.GetBytes(ev.Unsigned(), "prev_content.history_visibility").String()
|
hisVis, err := ev.HistoryVisibility()
|
||||||
oldPrio, ok := historyVisibilityPriority[gomatrixserverlib.HistoryVisibility(prevHisVis)]
|
|
||||||
// if we can't get the previous history visibility, default to shared.
|
if err == nil && hisVis != "" {
|
||||||
if !ok {
|
prevHisVis := gjson.GetBytes(ev.Unsigned(), "prev_content.history_visibility").String()
|
||||||
oldPrio = historyVisibilityPriority[gomatrixserverlib.HistoryVisibilityShared]
|
oldPrio, ok := historyVisibilityPriority[gomatrixserverlib.HistoryVisibility(prevHisVis)]
|
||||||
}
|
// if we can't get the previous history visibility, default to shared.
|
||||||
// no OK check, since this should have been validated when setting the value
|
if !ok {
|
||||||
newPrio := historyVisibilityPriority[hisVis]
|
oldPrio = historyVisibilityPriority[gomatrixserverlib.HistoryVisibilityShared]
|
||||||
if oldPrio < newPrio {
|
}
|
||||||
evVis.visibility = gomatrixserverlib.HistoryVisibility(prevHisVis)
|
// no OK check, since this should have been validated when setting the value
|
||||||
|
newPrio := historyVisibilityPriority[hisVis]
|
||||||
|
if oldPrio < newPrio {
|
||||||
|
evVis.visibility = gomatrixserverlib.HistoryVisibility(prevHisVis)
|
||||||
|
} else {
|
||||||
|
evVis.visibility = hisVis
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do the actual check
|
// do the actual check
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue