diff --git a/matrix_appservice_kakaotalk/config.py b/matrix_appservice_kakaotalk/config.py index 7493f1c..872d5d5 100644 --- a/matrix_appservice_kakaotalk/config.py +++ b/matrix_appservice_kakaotalk/config.py @@ -67,6 +67,8 @@ class Config(BaseBridgeConfig): copy("metrics.enabled") copy("metrics.listen_port") + copy("kakaotalk.device_name") + copy("bridge.username_template") copy("bridge.displayname_template") copy("bridge.displayname_preference") diff --git a/matrix_appservice_kakaotalk/example-config.yaml b/matrix_appservice_kakaotalk/example-config.yaml index d4008ee..e3e7da6 100644 --- a/matrix_appservice_kakaotalk/example-config.yaml +++ b/matrix_appservice_kakaotalk/example-config.yaml @@ -83,6 +83,10 @@ manhole: whitelist: - 0 +# Config for things that are directly sent to KakaoTalk. +kakaotalk: + device_name: "KakaoTalk Bridge" + # Bridge config bridge: # Localpart template of MXIDs for KakaoTalk users. diff --git a/matrix_appservice_kakaotalk/kt/client/client.py b/matrix_appservice_kakaotalk/kt/client/client.py index 285ea59..23132e2 100644 --- a/matrix_appservice_kakaotalk/kt/client/client.py +++ b/matrix_appservice_kakaotalk/kt/client/client.py @@ -91,7 +91,7 @@ class Client: @classmethod def init_cls(cls, config: Config) -> None: """Initialize RPC to the Node backend.""" - cls._rpc_client = RPCClient(config) + cls._rpc_client = RPCClient(config, "kakaotalk") # NOTE No need to store this, as cancelling the RPCClient will cancel this too asyncio.create_task(cls._keep_connected()) diff --git a/matrix_appservice_kakaotalk/rpc/rpc.py b/matrix_appservice_kakaotalk/rpc/rpc.py index f3edb5f..97c5a62 100644 --- a/matrix_appservice_kakaotalk/rpc/rpc.py +++ b/matrix_appservice_kakaotalk/rpc/rpc.py @@ -87,8 +87,9 @@ class RPCClient: _is_disconnected: CancelableEvent _connection_lock: asyncio.Lock - def __init__(self, config: Config) -> None: + def __init__(self, config: Config, register_config_key: str) -> None: self.config = config + self.register_config_key = register_config_key self.loop = asyncio.get_running_loop() self._req_id = 0 self._min_broadcast_id = 0 @@ -144,7 +145,9 @@ class RPCClient: self._reader = r self._writer = w self._read_task = self.loop.create_task(self._try_read_loop()) - await self._raw_request("register", peer_id=self.config["appservice.address"]) + await self._raw_request("register", + peer_id=self.config["appservice.address"], + register_config=self.config[self.register_config_key]) self._is_connected.set() self._is_disconnected.clear() diff --git a/node/src/client.js b/node/src/client.js index 4f5322b..44ce8ff 100644 --- a/node/src/client.js +++ b/node/src/client.js @@ -362,6 +362,7 @@ export default class PeerClient { this.notificationID = 0 this.maxCommandID = 0 this.peerID = null + this.deviceName = "KakaoTalk Bridge" /** @type {Map} */ this.userClients = new Map() @@ -480,7 +481,7 @@ export default class PeerClient { * @param {string} uuid */ async #createAuthClient(uuid) { - return await AuthApiClient.create("KakaoTalk Bridge", uuid) + return await AuthApiClient.create(this.deviceName, uuid) } // TODO Wrapper for per-user commands @@ -865,9 +866,12 @@ export default class PeerClient { /** * @param {Object} req * @param {string} req.peer_id + * @param {Object} req.register_config + * @param {string} req.register_config.device_name */ handleRegister = async (req) => { this.peerID = req.peer_id + this.deviceName = req.register_config.device_name || this.deviceName this.log(`Registered socket ${this.connID} -> ${this.peerID}`) if (this.manager.clients.has(this.peerID)) { const oldClient = this.manager.clients.get(this.peerID)