-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify API for stanzas #3814
Unify API for stanzas #3814
Conversation
Codecov ReportBase: 83.03% // Head: 83.01% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #3814 +/- ##
==========================================
- Coverage 83.03% 83.01% -0.03%
==========================================
Files 529 528 -1
Lines 33886 33822 -64
==========================================
- Hits 28138 28076 -62
+ Misses 5748 5746 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
9cccf4e
to
25da911
Compare
This comment was marked as outdated.
This comment was marked as outdated.
25da911
to
689ad91
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
163bde2
to
d1f6c81
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
48a5bba
to
8cca662
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
f78be93
to
27bcfdd
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
27bcfdd
to
e27870e
Compare
This comment was marked as outdated.
This comment was marked as outdated.
e27870e
to
8cbd065
Compare
- Move functions from mongoose_stanza_helper, because there is no need for two separate modules here. - Perform a fold over individual steps to organize error handling. The 'fold' function can be later reused, and moved e.g. to mongoose_api_common. - Handle more error cases, that were caught only by graphql-specific code. Now the REST api handles them as well. - Allow stanza without 'from' when 'user' is known. 'from' is set to the user JID later in the routing process anyway. - Use Stanza ID not only for REST. MAM ID was used for GraphQL. We can add MAM ID as a separate GraphQL field when needed. - Set Stanza ID if the stanza does not already have one - this is similar to the behaviour for messages. - Do not treat 0 and <<>> values as undefined - this is a bit unexpected, and now in the unified API the user can always omit them when needed. - Set correct max_result_limit - previously it was set to 1.
- Call the new API, which makes it possible to ged rid of some checks. - Remove unused helper functions. - Make format_error/2 more flexible.
- The new API makes it possible to avoid some checks
8cbd065
to
a29930d
Compare
This comment was marked as outdated.
This comment was marked as outdated.
- The Id is a stanza Id now. - It is possible to send a stanza with predefined Id and/or without 'from'. - Update error messages.
- Update error messages - Test getting messages for a non-existent user
a29930d
to
4c81efb
Compare
This comment was marked as outdated.
This comment was marked as outdated.
get_id(Stanza) -> | ||
exml_query:attr(Stanza, <<"id">>, undefined). | ||
|
||
fold({_, _} = Result, _) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really enjoyed reading this fragment of code 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
The main goal is to make
mongoose_stanza_api
:{ok, Result}
or{ErrorReasonAtom, ErrorMsg}
like the remaining API modules.Functional changes
0
and<<>>
values as undefined - this was a bit unexpected, and now in the unified API the user can always omit them when needed.max_result_limit
- previously it was set to 1.mod_mam_pm
before querying the last messages with GraphQL. This is not done for REST, as we don't have a simple way to do it. We are not developing REST further anyway.Refactoring notes
mongoose_stanza_api
. We could reuse it in other modules as well (by moving to a separate module later on), but I don't want to force it. Anyway, thefold
function, which has all the logic, is very simple. The advantages are steps reusability (even between API's in the future), and readability (the happy path is easy to follow).