Skip to content
This repository was archived by the owner on Sep 19, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/fabric_doc_open.erl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ choose_reply(Docs) ->

format_reply({ok, #doc{deleted=true}}, true) ->
{not_found, deleted};
format_reply({ok, #doc{}=Doc}, _) ->
couch_doc_security:filter(Doc);
format_reply(Else, _) ->
Else.

Expand Down
11 changes: 10 additions & 1 deletion src/fabric_doc_open_revs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ go(DbName, Id, Revs, Options) ->
RexiMon = fabric_util:create_monitors(Workers),
try fabric_util:recv(Workers, #shard.ref, fun handle_message/3, State) of
{ok, {ok, Reply}} ->
{ok, Reply};
{ok, format_reply(Reply)};
{ok, Reply} ->
{ok, format_reply(Reply)};
Else ->
Else
after
Expand Down Expand Up @@ -139,6 +141,13 @@ maybe_reply(DbName, ReplyDict, Complete, RepairDocs, R) ->
noreply
end.

format_reply(DocList) ->
MapFun = fun
({ok, #doc{}=Doc}) -> couch_doc_security:filter(Doc);
(Else) -> Else
end,
lists:map(MapFun, DocList).

extract_replies(Replies) ->
lists:map(fun({_,{Reply,_}}) -> Reply end, Replies).

Expand Down
3 changes: 2 additions & 1 deletion src/fabric_view.erl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ transform_row(#view_row{key=Key, id=Id, value=Value, doc=undefined}) ->
{row, {[{id,Id}, {key,Key}, {value,Value}]}};
transform_row(#view_row{key=Key, id=Id, value=Value, doc={error,Reason}}) ->
{row, {[{id,Id}, {key,Key}, {value,Value}, {error,Reason}]}};
transform_row(#view_row{key=Key, id=Id, value=Value, doc=Doc}) ->
transform_row(#view_row{key=Key, id=Id, value=Value, doc=Doc0}) ->
{ok, Doc} = couch_doc_security:filter(Doc0),
{row, {[{id,Id}, {key,Key}, {value,Value}, {doc,Doc}]}}.


Expand Down
3 changes: 3 additions & 0 deletions src/fabric_view_changes.erl
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ changes_row(Props0, IncludeDocs) ->
{true, {error, Reason}} ->
% Transform {doc, {error, Reason}} to {error, Reason} for JSON
lists:keyreplace(doc, 1, Props0, {error, Reason});
{true, Doc0} when Doc0 /= undefined ->
{ok, Doc} = couch_doc_security:filter(Doc0),
lists:keyreplace(doc, 1, Props0, {doc, Doc});
{false, _} ->
lists:keydelete(doc, 1, Props0);
_ ->
Expand Down