Skip to content

Conversation

@slipeer
Copy link

@slipeer slipeer commented Jul 18, 2018

Methods

  • download
  • thumbnail
  • preview_url

and tests for it.

Attemp to close issue #150

Signed-off-by: Pavel Kardash slipeer@gmail.com

@Zil0 Zil0 mentioned this pull request Aug 5, 2018
@slipeer slipeer force-pushed the thumbnails branch 3 times, most recently from d785c7c to 47bee9a Compare August 10, 2018 06:51
@non-Jedi
Copy link
Collaborator

non-Jedi commented Sep 2, 2018

@Zil0 since you touch this in your E2E stuff, could you take a look at this to make sure there are no conflicts with how you're implementing things?

)

return response.json()
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be unclear why this is here without the context of the PR. More importantly, this doesn't feel very robust, what if the file to download is actually JSON?

I'd fix this by passing a new boolean to _send, not sure if this is the best way though.

raise ValueError("MXC URL did not begin with 'mxc://'")

def media_download(self, mxcurl):
""" Download raw media from provided mxc URL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should get rid of the space after """, and add a . at the end of this line (applies to all of your docstrings).

method (str): thumb creation method. Must be
in ['scale', 'crop']. Default 'scale'.
"""
if method.lower() not in ['scale', 'crop']:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if tolerating improper case is useful, or consistent with the rest of the API methods.

@Zil0
Copy link
Contributor

Zil0 commented Sep 2, 2018

All is fine, this will just simplify things a bit :)

I've written down some thoughts I had when reading the code, but this is not a proper review.

@slipeer slipeer force-pushed the thumbnails branch 3 times, most recently from 4dca37b to ab48e0a Compare September 3, 2018 07:08
@slipeer
Copy link
Author

slipeer commented Sep 3, 2018

@Zil0 I fixed PR code for your comments.

query_params={
"width": width,
"height": height,
"method": method.lower()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lower is not needed anymore here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups... Removed

Args:
mxcurl (str): mxc media URL
width (int): required thumbnail width
height (int): required thumbnail height
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well say "desired" instead of "required" here since the spec insists on this.

@Zil0
Copy link
Contributor

Zil0 commented Sep 9, 2018

For completeness sake you may want to add the allow_remote query param to media_download and get_thumbnail, which was introduced in r0.4.0.

This is not needed for this to be merged though, just fix the conflicts and it will be good to go :)

@slipeer slipeer force-pushed the thumbnails branch 4 times, most recently from de39b44 to 16a2c32 Compare September 11, 2018 06:33
@slipeer
Copy link
Author

slipeer commented Sep 11, 2018

Conflict removed.
Added support for allow_remote query parameter
Corrected documentation lines.
@Zil0, will that be better?

@Zil0 Zil0 merged commit c107942 into matrix-org:master Sep 11, 2018
@Zil0
Copy link
Contributor

Zil0 commented Sep 11, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants