Move historyVisibility

This commit is contained in:
Till Faelligen 2023-11-23 19:48:53 +01:00
parent 7999ef09d5
commit 0f74cbfb27
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E

View file

@ -71,13 +71,12 @@ func (r *Inputer) updateLatestEvents(
defer sqlutil.EndTransactionWithCheck(updater, &succeeded, &err) defer sqlutil.EndTransactionWithCheck(updater, &succeeded, &err)
u := latestEventsUpdater{ u := latestEventsUpdater{
ctx: ctx, ctx: ctx,
api: r, api: r,
updater: updater, updater: updater,
stateAtEvent: stateAtEvent, stateAtEvent: stateAtEvent,
event: event, event: event,
rewritesState: rewritesState, rewritesState: rewritesState,
historyVisibility: historyVisibility,
} }
var updates []api.OutputEvent var updates []api.OutputEvent
@ -86,7 +85,7 @@ func (r *Inputer) updateLatestEvents(
return fmt.Errorf("u.doUpdateLatestEvents: %w", err) return fmt.Errorf("u.doUpdateLatestEvents: %w", err)
} }
update, err := u.makeOutputNewRoomEvent(transactionID, sendAsServer, updater.LastEventIDSent()) update, err := u.makeOutputNewRoomEvent(transactionID, sendAsServer, updater.LastEventIDSent(), historyVisibility)
if err != nil { if err != nil {
return fmt.Errorf("u.makeOutputNewRoomEvent: %w", err) return fmt.Errorf("u.makeOutputNewRoomEvent: %w", err)
} }
@ -139,8 +138,6 @@ type latestEventsUpdater struct {
// The snapshots of current state before and after processing this event // The snapshots of current state before and after processing this event
oldStateNID types.StateSnapshotNID oldStateNID types.StateSnapshotNID
newStateNID types.StateSnapshotNID newStateNID types.StateSnapshotNID
// The history visibility of the event itself (from the state before the event).
historyVisibility gomatrixserverlib.HistoryVisibility
} }
func (u *latestEventsUpdater) doUpdateLatestEvents(roomInfo *types.RoomInfo) ([]api.OutputEvent, error) { func (u *latestEventsUpdater) doUpdateLatestEvents(roomInfo *types.RoomInfo) ([]api.OutputEvent, error) {
@ -379,7 +376,12 @@ func (u *latestEventsUpdater) calculateLatest(
return true, nil return true, nil
} }
func (u *latestEventsUpdater) makeOutputNewRoomEvent(transactionID *api.TransactionID, sendAsServer string, lastEventIDSent string) (*api.OutputEvent, error) { func (u *latestEventsUpdater) makeOutputNewRoomEvent(
transactionID *api.TransactionID,
sendAsServer string,
lastEventIDSent string,
historyVisibility gomatrixserverlib.HistoryVisibility,
) (*api.OutputEvent, error) {
latestEventIDs := make([]string, len(u.latest)) latestEventIDs := make([]string, len(u.latest))
for i := range u.latest { for i := range u.latest {
latestEventIDs[i] = u.latest[i].EventID latestEventIDs[i] = u.latest[i].EventID
@ -392,7 +394,7 @@ func (u *latestEventsUpdater) makeOutputNewRoomEvent(transactionID *api.Transact
LatestEventIDs: latestEventIDs, LatestEventIDs: latestEventIDs,
TransactionID: transactionID, TransactionID: transactionID,
SendAsServer: sendAsServer, SendAsServer: sendAsServer,
HistoryVisibility: u.historyVisibility, HistoryVisibility: historyVisibility,
} }
eventIDMap, err := u.stateEventMap() eventIDMap, err := u.stateEventMap()