UserHasDocAccess checks whether the user has access to the active revision of the document
(ctx context.Context, collection *DatabaseCollectionWithUser, docID string)
| 381 | |
| 382 | // UserHasDocAccess checks whether the user has access to the active revision of the document |
| 383 | func UserHasDocAccess(ctx context.Context, collection *DatabaseCollectionWithUser, docID string) (bool, error) { |
| 384 | currentRev, err := collection.revisionCache.GetActive(ctx, docID) |
| 385 | if err != nil { |
| 386 | if base.IsDocNotFoundError(err) { |
| 387 | return false, nil |
| 388 | } |
| 389 | return false, err |
| 390 | } |
| 391 | |
| 392 | if collection.user == nil { |
| 393 | return true, nil |
| 394 | } |
| 395 | |
| 396 | authErr := collection.user.AuthorizeAnyCollectionChannel(collection.ScopeName, collection.Name, currentRev.Channels) |
| 397 | return authErr == nil, nil |
| 398 | } |
| 399 | |
| 400 | // Checks if a document needs to be revoked. This is used in the case where the since < doc sequence |
| 401 | func (col *DatabaseCollectionWithUser) wasDocInChannelPriorToRevocation(ctx context.Context, syncData SyncData, docID, chanName string, since uint64) (bool, error) { |