summary refs log tree commit diff
path: root/synapse/rest/media/v1/thumbnail_resource.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Refactor media modules. (#15146)Patrick Cloke2023-02-271-555/+0
| | | | | | | * Removes the `v1` directory from `test.rest.media.v1`. * Moves the non-REST code from `synapse.rest.media.v1` to `synapse.media`. * Flatten the `v1` directory from `synapse.rest.media`, but leave compatiblity with 3rd party media repositories and spam checkers.
* Stop parsing the unspecced type parameter on thumbnail requests. (#15137)Patrick Cloke2023-02-231-1/+2
| | | | | | | | Ideally we would replace this with parsing of the Accept header or something else, but for now just make Synapse spec compliant by ignoring the unspecced parameter. It does not seem that this is ever sent by a client, and even if it is there's a reasonable fallback.
* Provide more info why we don't have any thumbnails to serve (#13038)Eric Eastwood2022-07-151-2/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix https://github.com/matrix-org/synapse/issues/13016 ## New error code and status ### Before Previously, we returned a `404` for `/thumbnail` which isn't even in the spec. ```json { "errcode": "M_NOT_FOUND", "error": "Not found [b'hs1', b'tefQeZhmVxoiBfuFQUKRzJxc']" } ``` ### After What does the spec say? > 400: The request does not make sense to the server, or the server cannot thumbnail the content. For example, the client requested non-integer dimensions or asked for negatively-sized images. > > *-- https://spec.matrix.org/v1.1/client-server-api/#get_matrixmediav3thumbnailservernamemediaid* Now with this PR, we respond with a `400` when we don't have thumbnails to serve and we explain why we might not have any thumbnails. ```json { "errcode": "M_UNKNOWN", "error": "Cannot find any thumbnails for the requested media ([b'example.com', b'12345']). This might mean the media is not a supported_media_format=(image/jpeg, image/jpg, image/webp, image/gif, image/png) or that thumbnailing failed for some other reason. (Dynamic thumbnails are disabled on this server.)", } ``` > Cannot find any thumbnails for the requested media ([b'example.com', b'12345']). This might mean the media is not a supported_media_format=(image/jpeg, image/jpg, image/webp, image/gif, image/png) or that thumbnailing failed for some other reason. (Dynamic thumbnails are disabled on this server.) --- We still respond with a 404 in many other places. But we can iterate on those later and maybe keep some in some specific places after spec updates/clarification: https://github.com/matrix-org/matrix-spec/issues/1122 We can also iterate on the bugs where Synapse doesn't thumbnail when it should in other issues/PRs.
* Add Cross-Origin-Resource-Policy header to thumbnail and download media ↵Robert Long2022-06-271-1/+6
| | | | endpoints (#12944)
* Remove `HomeServer.get_datastore()` (#12031)Richard van der Hoff2022-02-231-1/+1
| | | | | | | The presence of this method was confusing, and mostly present for backwards compatibility. Let's get rid of it. Part of #11733
* Use direct references for configuration variables (part 5). (#10897)Patrick Cloke2021-09-241-1/+1
|
* Add reactor to `SynapseRequest` and fix up types. (#10868)Erik Johnston2021-09-241-8/+7
|
* Convert media repo's FileInfo to attrs. (#10785)Patrick Cloke2021-09-141-35/+42
| | | | This is mostly an internal change, but improves type hints in the media code.
* Fix error when selecting between thumbnails with the same quality (#10684)Sean2021-08-251-9/+17
| | | Fixes #10318
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
| | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Import HomeServer from the proper module. (#9665)Patrick Cloke2021-03-231-1/+1
|
* Use the proper Request in type hints. (#9515)Patrick Cloke2021-03-011-1/+1
| | | | This also pins the Twisted version in the mypy job for CI until proper type hints are fixed throughout Synapse.
* Return a 404 if we don't have the original fileErik Johnston2021-02-191-0/+7
|
* Regenerate exact thumbnails if missingErik Johnston2021-02-181-1/+48
|
* Return a 404 if no valid thumbnail is found. (#9163)Patrick Cloke2021-01-211-81/+155
| | | | | | If no thumbnail of the requested type exists, return a 404 instead of erroring. This doesn't quite match the spec (which does not define what happens if no thumbnail can be found), but is consistent with what Synapse already does.
* Add type hints to media rest resources. (#9093)Patrick Cloke2021-01-151-27/+54
|
* Do not error when thumbnailing invalid files (#8236)Patrick Cloke2020-09-091-2/+3
| | | | If a file cannot be thumbnailed for some reason (e.g. the file is empty), then catch the exception and convert it to a reasonable error message for the client.
* Merge different Resource implementation classes (#7732)Erik Johnston2020-07-031-8/+2
|
* Convert some of the media REST code to async/await (#7110)Patrick Cloke2020-03-201-30/+24
|
* Fix typo in _select_thumbnailBrendan Abolivier2020-01-221-1/+1
|
* Fixup synapse.rest to pass mypy (#6732)Erik Johnston2020-01-201-7/+7
|
* Remove usage of deprecated logger.warn method from codebase (#6271)Andrew Morgan2019-10-311-2/+2
| | | Replace every instance of `logger.warn` with `logger.warning` as the former is deprecated.
* Make the http server handle coroutine-making REST servlets (#5475)Amber Brown2019-06-291-15/+12
|
* Run Black. (#5482)Amber Brown2019-06-201-39/+81
|
* Fix error when downloading thumbnail with width/height param missing (#5258)Aaron Raimist2019-05-291-2/+2
| | | | | | | Fix error when downloading thumbnail with width/height param missing Fixes #2748 Signed-off-by: Aaron Raimist <aaron@raim.ist>
* run isortAmber Brown2018-07-091-5/+6
|
* Set Server header in SynapseRequestRichard van der Hoff2018-05-101-1/+0
| | | | | | | | | | | | (instead of everywhere that writes a response. Or rather, the subset of places which write responses where we haven't forgotten it). This also means that we don't have to have the mysterious version_string attribute in anything with a request handler. Unfortunately it does mean that we have to pass the version string wherever we instantiate a SynapseSite, which has been c&ped 150 times, but that is code that ought to be cleaned up anyway really.
* Remove redundant request_handler decoratorRichard van der Hoff2018-05-101-10/+13
| | | | | | This is needless complexity; we might as well use the wrapper directly. Also rename wrap_request_handler->wrap_json_request_handler.
* Merge pull request #2791 from matrix-org/erikj/media_storage_refactorErik Johnston2018-02-051-1/+2
|\ | | | | Ensure media is in local cache before thumbnailing
| * Ensure media is in local cache before thumbnailingErik Johnston2018-01-181-1/+2
| |
* | Fix typo in thumbnail resource causing access times to be incorrectErik Johnston2018-01-181-2/+2
| |
* | Update last access time when thumbnails are viewedErik Johnston2018-01-171-0/+2
|/
* Fix typoErik Johnston2018-01-161-7/+10
|
* Fix up log linesErik Johnston2018-01-161-6/+9
|
* Correctly use server_name/file_id when generating/fetching remote thumbnailsErik Johnston2018-01-161-3/+3
|
* Log when we respond with 404Erik Johnston2018-01-161-1/+7
|
* Fix thumbnailing remote filesErik Johnston2018-01-161-2/+2
|
* Merge pull request #2767 from matrix-org/erikj/media_storage_refactorErik Johnston2018-01-161-47/+65
|\ | | | | Refactor MediaRepository to separate out storage
| * Make ThumbnailResource use MediaStorageErik Johnston2018-01-091-47/+65
| |
* | Reinstate media download on thumbnail requestRichard van der Hoff2018-01-121-0/+5
|/ | | | | We need to actually download the remote media when we get a request for a thumbnail.
* Remove dead TODOErik Johnston2018-01-091-2/+0
|
* Remove dead code related to default thumbnailsErik Johnston2018-01-091-73/+3
|
* Store URL cache preview downloads seperatelyErik Johnston2017-06-231-6/+22
| | | | This makes it easier to clear old media out at a later date
* Add API to quarantine mediaErik Johnston2017-06-191-2/+2
|
* Set CORs headers on responses from the media repoMark Haines2016-11-021-1/+2
|
* Report per request metrics for all of the things using request_handlerMark Haines2016-04-281-1/+2
|
* Move MediaRepository to media_repository moduleErik Johnston2016-04-191-1/+1
|
* Split out BaseMediaResource into MediaRepositoryErik Johnston2016-04-191-20/+31
| | | | | | | | | This is so that a single MediaRepository can be shared across all resources, rather than having a "copy" per resource. In particular this allows us to guard against both the thumbnail and download resource triggering a download of remote content at the same time.
* comment out 2c838f6459db35ad9812a83184d85a06ca5d940a due to risk of ↵Matthew Hodgson2016-04-141-16/+16
| | | | https://en.wikipedia.org/wiki/Billion_laughs attacks - thanks @torhve
* how was _respond_default_thumbnail ever meant to work?Matthew Hodgson2016-04-021-0/+2
|
* pass back SVGs as their own thumbnailsMatthew Hodgson2016-04-021-0/+20
|
* Only use cropped thumbnails when asked for a cropped thumbnail.Mark Haines2016-01-071-1/+1
| | | | Even though ones cropped with scale might be technically valid.
* Allow guests to upgrade their accountsDaniel Wagner-Hall2016-01-051-1/+1
|
* Use larger thumbnail rather than smaller.Erik Johnston2016-01-051-4/+13
|
* Make a config option for whether to generate new thumbnail sizes dynamicallyMark Haines2015-08-121-7/+18
|
* Fix remote thumbnailingErik Johnston2015-07-231-6/+10
|
* Always return a thumbnail of the requested size.Erik Johnston2015-07-231-2/+79
| | | | | | Before, we returned a thumbnail that was at least as big (if possible) as the requested size. Now, if we don't have a thumbnail of the given size we generate (and persist) one of that size.
* Pick larger than desired thumbnail for 'crop'Erik Johnston2015-07-231-1/+2
|
* If user supplies filename in URL when downloading from media repo, use that ↵Erik Johnston2015-07-031-1/+1
| | | | name in Content Disposition
* Combine the request wrappers in rest/media/v1 and http/server into a single ↵Mark Haines2015-04-211-7/+9
| | | | wrapper decorator
* Move rest APIs back under the rest directoryMark Haines2015-01-221-0/+193