
import logging

from synapse.http.client import SimpleHttpClient
from synapse.http.servlet import (
    RestServlet,
    parse_json_object_from_request,
)
from synapse.http.site import SynapseRequest
from synapse.rest.client.v2_alpha._base import client_patterns

logger = logging.getLogger(__name__)

class SMSCallback(RestServlet):
    # PATTERNS = [re.compile("^/_matrix/client/sms/callback$")]
    PATTERNS = client_patterns("/sms/callback$", v1=True)

    def __init__(self, hs):
        super().__init__()
        self.hs = hs
        # self.auth = hs.get_auth()

        self.http_client = SimpleHttpClient(hs)

    async def on_POST(self, request: SynapseRequest):

        params = parse_json_object_from_request(request)
        logger.info("-----smscallback-------param:%s" % (str(params)))


        return 200, {}


def register_servlets(hs, http_server):
    SMSCallback(hs).register(http_server)


import logging

from synapse.http.client import SimpleHttpClient
from synapse.http.servlet import (
    RestServlet,
    parse_json_object_from_request,
)
from synapse.http.site import SynapseRequest
from synapse.rest.client.v2_alpha._base import client_patterns

logger = logging.getLogger(__name__)

class SMSCallback(RestServlet):
    # PATTERNS = [re.compile("^/_matrix/client/sms/callback$")]
    PATTERNS = client_patterns("/sms/callback$", v1=True)

    def __init__(self, hs):
        super().__init__()
        self.hs = hs
        # self.auth = hs.get_auth()

        self.http_client = SimpleHttpClient(hs)

    async def on_POST(self, request: SynapseRequest):

        params = parse_json_object_from_request(request)
        logger.info("-----smscallback-------param:%s" % (str(params)))


        return 200, {}


def register_servlets(hs, http_server):
    SMSCallback(hs).register(http_server)

# PATTERNS = [re.compile("^/_matrix/client/sms/callback$")] # self.auth = hs.get_auth()