From b4c49a709940b225322a51459621a9e9d847f840 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Tue, 12 Dec 2017 01:08:32 +0000 Subject: [PATCH] Ensure that the NS and DB are available to the live query --- db/lives.go | 2 +- db/socket.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/db/lives.go b/db/lives.go index b1cb646f..981af65c 100644 --- a/db/lives.go +++ b/db/lives.go @@ -52,7 +52,7 @@ func (d *document) lives(ctx context.Context, when method) (err error) { if con, ok = sockets[lv.FB]; ok { - ctx = con.ctx() + ctx = con.ctx(d.ns, d.db) // Check whether this live query has the // necessary permissions to view this diff --git a/db/socket.go b/db/socket.go index 317bcdba..ff08b796 100644 --- a/db/socket.go +++ b/db/socket.go @@ -48,10 +48,13 @@ func flush() { } } -func (s *socket) ctx() (ctx context.Context) { +func (s *socket) ctx(ns, db string) (ctx context.Context) { ctx = context.Background() + ctx = context.WithValue(ctx, ctxKeyNs, ns) + ctx = context.WithValue(ctx, ctxKeyDb, db) + auth := s.fibre.Get(varKeyAuth).(*cnf.Auth) ctx = context.WithValue(ctx, ctxKeyAuth, auth.Data) ctx = context.WithValue(ctx, ctxKeyKind, auth.Kind)