MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / getHistoricRoleChanEntryOverlap

Function getHistoricRoleChanEntryOverlap

rest/diagnostic_api.go:171–196  ·  view source on GitHub ↗

Only used for deleted role, logic is for channels in channel_history and roles in role_history

(roleEntries []auth.GrantHistorySequencePair, chanEntries []auth.GrantHistorySequencePair)

Source from the content-addressed store, hash-verified

169
170// Only used for deleted role, logic is for channels in channel_history and roles in role_history
171func getHistoricRoleChanEntryOverlap(roleEntries []auth.GrantHistorySequencePair, chanEntries []auth.GrantHistorySequencePair) []auth.GrantHistorySequencePair {
172 var overlapEntries []auth.GrantHistorySequencePair
173 var entry auth.GrantHistorySequencePair
174 for _, roleEntry := range roleEntries {
175 for _, chanEntry := range chanEntries {
176 // default
177 entry = auth.GrantHistorySequencePair{StartSeq: chanEntry.StartSeq, EndSeq: roleEntry.EndSeq}
178 // role was assigned to user after chan was removed from role, no entry
179 if roleEntry.StartSeq > chanEntry.EndSeq {
180 continue
181 // role was removed from user before chan was assigned to role, no entry
182 } else if roleEntry.EndSeq < chanEntry.StartSeq {
183 continue
184 // chan was removed from role after role was removed from user
185 } else if chanEntry.EndSeq > roleEntry.EndSeq {
186 entry = auth.GrantHistorySequencePair{StartSeq: chanEntry.StartSeq, EndSeq: roleEntry.EndSeq}
187 // role was assigned to user after chan was assigned to role
188 } else if roleEntry.StartSeq > chanEntry.StartSeq {
189 entry = auth.GrantHistorySequencePair{StartSeq: roleEntry.StartSeq, EndSeq: chanEntry.EndSeq}
190 }
191 overlapEntries = append(overlapEntries, entry)
192 }
193 }
194
195 return overlapEntries
196}
197
198func (h *handler) handleGetAllChannels() error {
199 h.assertAdminOnly()

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected