mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-23 18:56:10 +00:00
make it build
This commit is contained in:
parent
e0c2490a14
commit
dd4287ca5d
@ -21,7 +21,7 @@ import synapse.metrics
|
|||||||
|
|
||||||
from canonicaljson import encode_canonical_json
|
from canonicaljson import encode_canonical_json
|
||||||
|
|
||||||
from twisted.internet import defer, reactor, ssl
|
from twisted.internet import defer, reactor, ssl, protocol
|
||||||
from twisted.web.client import (
|
from twisted.web.client import (
|
||||||
Agent, readBody, FileBodyProducer, PartialDownloadError,
|
Agent, readBody, FileBodyProducer, PartialDownloadError,
|
||||||
)
|
)
|
||||||
|
@ -36,6 +36,7 @@ REQUIREMENTS = {
|
|||||||
"blist": ["blist"],
|
"blist": ["blist"],
|
||||||
"pysaml2>=3.0.0,<4.0.0": ["saml2>=3.0.0,<4.0.0"],
|
"pysaml2>=3.0.0,<4.0.0": ["saml2>=3.0.0,<4.0.0"],
|
||||||
"pymacaroons-pynacl": ["pymacaroons"],
|
"pymacaroons-pynacl": ["pymacaroons"],
|
||||||
|
"lxml>=3.6.0": ["lxml"],
|
||||||
}
|
}
|
||||||
CONDITIONAL_REQUIREMENTS = {
|
CONDITIONAL_REQUIREMENTS = {
|
||||||
"web_client": {
|
"web_client": {
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from twisted.web.resource import Resource
|
from twisted.web.resource import Resource
|
||||||
|
from twisted.internet import defer
|
||||||
from lxml import html
|
from lxml import html
|
||||||
from synapse.http.client import SimpleHttpClient
|
from synapse.http.client import SimpleHttpClient
|
||||||
from synapse.http.server import respond_with_json_bytes
|
from synapse.http.server import request_handler, respond_with_json_bytes
|
||||||
from simplejson import json
|
import ujson as json
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -75,7 +76,7 @@ class PreviewUrlResource(Resource):
|
|||||||
# "og:url" : "https://twitter.com/matrixdotorg/status/684074366691356672"
|
# "og:url" : "https://twitter.com/matrixdotorg/status/684074366691356672"
|
||||||
# "og:title" : "Matrix on Twitter"
|
# "og:title" : "Matrix on Twitter"
|
||||||
# "og:image" : "https://pbs.twimg.com/profile_images/500400952029888512/yI0qtFi7_400x400.png"
|
# "og:image" : "https://pbs.twimg.com/profile_images/500400952029888512/yI0qtFi7_400x400.png"
|
||||||
# "og:description" : "“Synapse 0.12 is out! Lots of polishing, performance &amp; bugfixes: /sync API, /r0 prefix, fulltext search, 3PID invites https://t.co/5alhXLLEGP”"
|
# "og:description" : "Synapse 0.12 is out! Lots of polishing, performance &amp; bugfixes: /sync API, /r0 prefix, fulltext search, 3PID invites https://t.co/5alhXLLEGP"
|
||||||
# "og:site_name" : "Twitter"
|
# "og:site_name" : "Twitter"
|
||||||
|
|
||||||
og = {}
|
og = {}
|
||||||
@ -143,15 +144,15 @@ class PreviewUrlResource(Resource):
|
|||||||
os.remove(fname)
|
os.remove(fname)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return {
|
yield ({
|
||||||
"media_type": media_type,
|
"media_type": media_type,
|
||||||
"media_length": length,
|
"media_length": length,
|
||||||
"download_name": download_name,
|
"download_name": download_name,
|
||||||
"created_ts": time_now_ms,
|
"created_ts": time_now_ms,
|
||||||
"filesystem_id": file_id,
|
"filesystem_id": file_id,
|
||||||
"filename": fname,
|
"filename": fname,
|
||||||
}
|
})
|
||||||
|
return
|
||||||
|
|
||||||
def _is_media(content_type):
|
def _is_media(content_type):
|
||||||
if content_type.lower().startswith("image/"):
|
if content_type.lower().startswith("image/"):
|
||||||
@ -159,6 +160,6 @@ class PreviewUrlResource(Resource):
|
|||||||
|
|
||||||
def _is_html(content_type):
|
def _is_html(content_type):
|
||||||
content_type = content_type.lower()
|
content_type = content_type.lower()
|
||||||
if content_type == "text/html" or
|
if (content_type == "text/html" or
|
||||||
content_type.startswith("application/xhtml"):
|
content_type.startswith("application/xhtml")):
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user