prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Add a capabilties flag for MSC3440
  Per https://github.com/matrix-org/matrix-doc/commit/fc81bbd836955876c931c95277249981b3e2778c
  
  
  
  </issue>
  <code>
  [start of synapse/rest/client/capabilities.py]
  1 # Copyright 2019 New Vector
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 import logging
  15 from typing import TYPE_CHECKING, Tuple
  16 
  17 from synapse.api.room_versions import KNOWN_ROOM_VERSIONS, MSC3244_CAPABILITIES
  18 from synapse.http.server import HttpServer
  19 from synapse.http.servlet import RestServlet
  20 from synapse.http.site import SynapseRequest
  21 from synapse.types import JsonDict
  22 
  23 from ._base import client_patterns
  24 
  25 if TYPE_CHECKING:
  26     from synapse.server import HomeServer
  27 
  28 logger = logging.getLogger(__name__)
  29 
  30 
  31 class CapabilitiesRestServlet(RestServlet):
  32     """End point to expose the capabilities of the server."""
  33 
  34     PATTERNS = client_patterns("/capabilities$")
  35 
  36     def __init__(self, hs: "HomeServer"):
  37         super().__init__()
  38         self.hs = hs
  39         self.config = hs.config
  40         self.auth = hs.get_auth()
  41         self.auth_handler = hs.get_auth_handler()
  42 
  43     async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
  44         await self.auth.get_user_by_req(request, allow_guest=True)
  45         change_password = self.auth_handler.can_change_password()
  46 
  47         response: JsonDict = {
  48             "capabilities": {
  49                 "m.room_versions": {
  50                     "default": self.config.server.default_room_version.identifier,
  51                     "available": {
  52                         v.identifier: v.disposition
  53                         for v in KNOWN_ROOM_VERSIONS.values()
  54                     },
  55                 },
  56                 "m.change_password": {"enabled": change_password},
  57             }
  58         }
  59 
  60         if self.config.experimental.msc3244_enabled:
  61             response["capabilities"]["m.room_versions"][
  62                 "org.matrix.msc3244.room_capabilities"
  63             ] = MSC3244_CAPABILITIES
  64 
  65         if self.config.experimental.msc3283_enabled:
  66             response["capabilities"]["org.matrix.msc3283.set_displayname"] = {
  67                 "enabled": self.config.registration.enable_set_displayname
  68             }
  69             response["capabilities"]["org.matrix.msc3283.set_avatar_url"] = {
  70                 "enabled": self.config.registration.enable_set_avatar_url
  71             }
  72             response["capabilities"]["org.matrix.msc3283.3pid_changes"] = {
  73                 "enabled": self.config.registration.enable_3pid_changes
  74             }
  75 
  76         return 200, response
  77 
  78 
  79 def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
  80     CapabilitiesRestServlet(hs).register(http_server)
  81
  [end of synapse/rest/client/capabilities.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/synapse/rest/client/capabilities.py b/synapse/rest/client/capabilities.py
  --- a/synapse/rest/client/capabilities.py
  +++ b/synapse/rest/client/capabilities.py
  @@ -73,6 +73,9 @@
                   "enabled": self.config.registration.enable_3pid_changes
               }
   
  +        if self.config.experimental.msc3440_enabled:
  +            response["capabilities"]["io.element.thread"] = {"enabled": True}
  +
           return 200, response
  
verification_info: {"golden_diff": "diff --git a/synapse/rest/client/capabilities.py b/synapse/rest/client/capabilities.py\n--- a/synapse/rest/client/capabilities.py\n+++ b/synapse/rest/client/capabilities.py\n@@ -73,6 +73,9 @@\n                 \"enabled\": self.config.registration.enable_3pid_changes\n             }\n \n+        if self.config.experimental.msc3440_enabled:\n+            response[\"capabilities\"][\"io.element.thread\"] = {\"enabled\": True}\n+\n         return 200, response\n", "issue": "Add a capabilties flag for MSC3440\nPer https://github.com/matrix-org/matrix-doc/commit/fc81bbd836955876c931c95277249981b3e2778c\r\n\r\n\n", "before_files": [{"content": "# Copyright 2019 New Vector\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport logging\nfrom typing import TYPE_CHECKING, Tuple\n\nfrom synapse.api.room_versions import KNOWN_ROOM_VERSIONS, MSC3244_CAPABILITIES\nfrom synapse.http.server import HttpServer\nfrom synapse.http.servlet import RestServlet\nfrom synapse.http.site import SynapseRequest\nfrom synapse.types import JsonDict\n\nfrom ._base import client_patterns\n\nif TYPE_CHECKING:\n    from synapse.server import HomeServer\n\nlogger = logging.getLogger(__name__)\n\n\nclass CapabilitiesRestServlet(RestServlet):\n    \"\"\"End point to expose the capabilities of the server.\"\"\"\n\n    PATTERNS = client_patterns(\"/capabilities$\")\n\n    def __init__(self, hs: \"HomeServer\"):\n        super().__init__()\n        self.hs = hs\n        self.config = hs.config\n        self.auth = hs.get_auth()\n        self.auth_handler = hs.get_auth_handler()\n\n    async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:\n        await self.auth.get_user_by_req(request, allow_guest=True)\n        change_password = self.auth_handler.can_change_password()\n\n        response: JsonDict = {\n            \"capabilities\": {\n                \"m.room_versions\": {\n                    \"default\": self.config.server.default_room_version.identifier,\n                    \"available\": {\n                        v.identifier: v.disposition\n                        for v in KNOWN_ROOM_VERSIONS.values()\n                    },\n                },\n                \"m.change_password\": {\"enabled\": change_password},\n            }\n        }\n\n        if self.config.experimental.msc3244_enabled:\n            response[\"capabilities\"][\"m.room_versions\"][\n                \"org.matrix.msc3244.room_capabilities\"\n            ] = MSC3244_CAPABILITIES\n\n        if self.config.experimental.msc3283_enabled:\n            response[\"capabilities\"][\"org.matrix.msc3283.set_displayname\"] = {\n                \"enabled\": self.config.registration.enable_set_displayname\n            }\n            response[\"capabilities\"][\"org.matrix.msc3283.set_avatar_url\"] = {\n                \"enabled\": self.config.registration.enable_set_avatar_url\n            }\n            response[\"capabilities\"][\"org.matrix.msc3283.3pid_changes\"] = {\n                \"enabled\": self.config.registration.enable_3pid_changes\n            }\n\n        return 200, response\n\n\ndef register_servlets(hs: \"HomeServer\", http_server: HttpServer) -> None:\n    CapabilitiesRestServlet(hs).register(http_server)\n", "path": "synapse/rest/client/capabilities.py"}]}