From 6fe4db6a58a34d0e1645e56826036ce8625dc506 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sun, 15 Apr 2018 01:53:36 +0100 Subject: [PATCH] Check permissions on the initial document when deleting When deleting a document, we need to check the visibility permissions using the initial document, as the current document will now have been emptied. As a result, no delete notifications were being delivered to LIVE queries. --- db/check.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/db/check.go b/db/check.go index 53b31d48..52da42d2 100644 --- a/db/check.go +++ b/db/check.go @@ -87,7 +87,16 @@ func (d *document) grant(ctx context.Context, met method) (ok bool, err error) { // a scoped request, return an error. if p, ok := tb.Perms.(*sql.PermExpression); ok { - val, err = d.i.e.fetch(ctx, p.Select, d.current) + switch met { + case _SELECT: + val, err = d.i.e.fetch(ctx, p.Select, d.current) + case _CREATE: + val, err = d.i.e.fetch(ctx, p.Select, d.current) + case _UPDATE: + val, err = d.i.e.fetch(ctx, p.Select, d.current) + case _DELETE: + val, err = d.i.e.fetch(ctx, p.Select, d.initial) + } } // If the permissions expressions