-
Notifications
You must be signed in to change notification settings - Fork 9
Added more methods to work with matrix endpoints #77
Conversation
…sgtypes are now accepting formatted_body
…nload, thumbnail, set_room_read_markers, create_room_alias, delete_room_alias
Hi @inaniyants, first of all thank you for opening this PR (and issues), it's highly appreciated and I'm happy you've agreed to consolidate our efforts! As this PR is quite large, I will need a little time to work through everything but after a cursory glance, this looks good. I've opened #81 to move the discussion related to the |
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.
This is looking good!
Thank you for including documentation and full test coverage, it's highly appreciated. I left a few comments, mostly notes requiring no change as well as a few suggestions.
|
||
[![GitHub Workflow Status](https://github.com/niklaslong/matrix-elixir-sdk/workflows/Elixir%20CI/badge.svg)](https://github.com/niklaslong/matrix-elixir-sdk/actions?query=workflow%3A%22Elixir+CI%22+branch%3Amaster) | ||
[![Hex.pm](https://img.shields.io/hexpm/v/matrix_sdk)](https://hex.pm/packages/matrix_sdk) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) |
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.
👍
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.
In next PR's I'm going to add coveralls to project and set minimal code coverage for successful build. Code coverage percent will be displayed as a badge here also.
What minimal code coverage percent I should set ?
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.
How about 90% for now? In general I'm not convinced code coverage should be a CI failing metric as I'd rather focus on tested functionality, but I think this number will leave us with some wiggle room and a decent measurement of the health of the tests.
end | ||
|
||
defp content(:text, %{body: body}), do: %{msgtype: "m.text", body: body} | ||
|
||
defp content(:text, body), do: %{msgtype: "m.text", body: body} |
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.
We should either remove this in future for consistency or document it.
|
||
@text_based_tests | ||
|> Enum.each(fn {type, msgtype} -> | ||
describe "message/4 with #{msgtype} type" do |
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.
See comment related to this in room_event.ex
.
Co-authored-by: Niklas Long <[email protected]>
Current PR description
As we use matrix protocol in a company I'm working right now, we have created https://github.com/Voronchuk/ex_matrix_api library to interact with matrix endpoints. Not so long ago, we have made a decision to unite our efforts with yours and to contribute to this repo instead.
In this PR I have implemented new methods to work with matrix endpoints, additional message types and formatting. Code coverage has been increased, right now it is 100%.
I have also added method to
Client
, which allows to run already constructedRequest
via client. For many reasons there could be necessity to buildRequest
separately from its execution. Before this PR, request could be constructed withMatrixSDK.Client.Request
and it could be executed withMatrixSDK.HTTPClient
(or any other client). But this requires too much boilerplate (like to read which http_client to use from configuration), so instead I suggest to have ability to runRequest
directly withMatrixSDK.Client
, which already knows how to read configuration and how to build default http client.Other thoughts
Also, after diving into how this library is working and is being developed, I have a suggestion:
Right now library has not clear boundaries between
MatrixSDK.Client
andMatrixSDK.Client.Request
modules, which causes too much duplication of code, docs and tests, which are hardening development, since it consumes a lot of time. As for me, main value of this lib lies inMatrixSDK.Client.Request
module (it's role is to build a Request with help of good specs and docs). There is no need to duplicate same methods into Client, since its role is only to take a request and execute it via http protocol. For most of cases code will look like:Thats why I suggest to clear
MatrixSDK.Client
from any methods, that are not related to request execution. This would greatly simplify development for contributors, but won't affect developers, who are using library.There also could be situations, when request should not be executed at all. For example: In most of cases
download
,thumbnail
methods are needed to generate some urls, but not to do actual download. But current convention requires developer to place this methods into Client, which requires also to handle download and to cover it with test (which I haven't done). For url generation we could implement some helper method:But right now there is no context module to place such methods (it could be
MatrixSDK.Client
, but currently its concern is quite blurred).It's hard to write and discuss all this in PR , so I suggest to do it via github issues or in your matrix room, etc.