create initial redlight_server_module.py script

This commit is contained in:
PC-Admin 2023-08-11 02:27:33 +08:00
parent 4e1dc12038
commit bc43794e40

View File

@ -1,27 +1,27 @@
import logging import logging
from synapse.module_api import ModuleApi
from twisted.web.http import OK, NO_CONTENT
import json import json
from synapse.module_api import ModuleApi
from twisted.web import http from twisted.web import http
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.defer import inlineCallbacks from twisted.internet.defer import inlineCallbacks
from twisted.web.server import NOT_DONE_YET from twisted.web.server import NOT_DONE_YET
from twisted.web.http import OK, NO_CONTENT
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class AbuseLookupModule: class RedlightServerModule:
def __init__(self, config: dict, api: ModuleApi): def __init__(self, config: dict, api: ModuleApi):
self._api = api self._api = api
# Register the abuse_lookup endpoint # Register the abuse_lookup endpoint
api.register_web_resource( api.register_web_resource(
"/_matrix/loj/v1/abuse_lookup", "/_matrix/loj/v1/abuse_lookup",
AbuseLookupResource(self) RedlightServerResource(self)
) )
logger.info("AbuseLookupModule initialized.") logger.info("RedlightServerModule initialized.")
class AbuseLookupResource: class RedlightServerResource:
isLeaf = True isLeaf = True
@ -97,5 +97,5 @@ class AbuseLookupResource:
def parse_config(config: dict) -> dict: def parse_config(config: dict) -> dict:
return config return config
def create_module(api: ModuleApi, config: dict) -> AbuseLookupModule: def create_module(api: ModuleApi, config: dict) -> RedlightServerModule:
return AbuseLookupModule(config, api) return RedlightServerModule(config, api)