Skip to content

Commit

Permalink
Fixing CR issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Janusz Jakubiec authored and Janusz Jakubiec committed Dec 8, 2022
1 parent fddaa0b commit f9447f2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion priv/graphql/schemas/admin/private.gql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Allow admin to set the user's private data
"""
type PrivateAdminMutation @protected @use(modules: ["mod_private"]){
"Set the user's private data"
setPrivate(user: JID!, elementString: XmlElement): String
setPrivate(user: JID!, elementString: XmlElement!): XmlElement
@protected(type: DOMAIN, args: ["user"]) @use(arg: "user")
}

Expand Down
2 changes: 1 addition & 1 deletion priv/graphql/schemas/user/private.gql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Allow user to set own private
"""
type PrivateUserMutation @protected @use(modules: ["mod_private"]){
"Set user's own private"
setPrivate(elementString: XmlElement!): String @use
setPrivate(elementString: XmlElement!): XmlElement @use
}

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ execute(_Ctx, _Obj, <<"setPrivate">>, #{<<"user">> := CallerJID,
<<"elementString">> := Element}) ->
case mod_private_api:private_set(CallerJID, Element) of
{ok, _} = Result -> Result;
Error -> make_error(Error, #{user => jid:to_binary(CallerJID), element => Element})
Error -> make_error(Error, #{user => jid:to_binary(CallerJID),
element => exml:to_binary(Element)})
end.
3 changes: 2 additions & 1 deletion src/graphql/user/mongoose_graphql_private_user_mutation.erl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
execute(#{user := CallerJID}, _Obj, <<"setPrivate">>, #{<<"elementString">> := Element}) ->
case mod_private_api:private_set(CallerJID, Element) of
{ok, _} = Result -> Result;
Error -> make_error(Error, #{user => jid:to_binary(CallerJID), element => Element})
Error -> make_error(Error, #{user => jid:to_binary(CallerJID),
element => exml:to_binary(Element)})
end.
6 changes: 3 additions & 3 deletions src/mod_private_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private_set(#jid{lserver = Domain} = JID, Xml) ->
true ->
{ok, HostType} = mongoose_domain_api:get_domain_host_type(Domain),
send_iq(set, Xml, JID, HostType),
{ok, ""};
{ok, Xml};
false ->
{not_found, io_lib:format("User ~s does not exist", [jid:to_binary(JID)])}
end.
Expand All @@ -35,8 +35,8 @@ do_private_get(JID, Element, Ns) ->
Xml = #xmlel{ name = Element, attrs = [{<<"xmlns">>, Ns}]},
{_, ResIq} = send_iq(get, Xml, JID, HostType),
[#xmlel{ name = <<"query">>,
attrs = [{<<"xmlns">>, ?NS_PRIVATE}],
children = [SubEl] }] = ResIq#iq.sub_el,
attrs = [{<<"xmlns">>, ?NS_PRIVATE}],
children = [SubEl] }] = ResIq#iq.sub_el,
{ok, SubEl}.

send_iq(Method, Xml, From = To = _JID, HostType) ->
Expand Down

0 comments on commit f9447f2

Please sign in to comment.