Inbound profile changes
This commit is contained in:
parent
cf83e86e78
commit
4c205104a9
@ -44,6 +44,7 @@ from ..types.client.client_session import LoginResult
|
||||
from ..types.chat import Chatlog, KnownChatType
|
||||
from ..types.chat.attachment import MentionStruct, ReplyAttachment
|
||||
from ..types.oauth import OAuthCredential, OAuthInfo
|
||||
from ..types.openlink.open_link_user_info import OpenLinkChannelUserInfo
|
||||
from ..types.packet.chat.kickout import KnownKickoutType, KickoutRes
|
||||
from ..types.request import (
|
||||
deserialize_result,
|
||||
@ -402,6 +403,11 @@ class Client:
|
||||
str(data["channelType"]),
|
||||
)
|
||||
|
||||
async def _on_profile_changed(self, data: dict[str, JSON]) -> None:
|
||||
await self.user.on_profile_changed(
|
||||
OpenLinkChannelUserInfo.deserialize(data["info"]),
|
||||
)
|
||||
|
||||
""" TODO
|
||||
async def _on_receipt(self, data: Dict[str, JSON]) -> None:
|
||||
await self.user.on_receipt(Receipt.deserialize(data["receipt"]))
|
||||
@ -430,6 +436,7 @@ class Client:
|
||||
def _start_listen(self) -> None:
|
||||
self._add_event_handler("chat", self._on_chat)
|
||||
self._add_event_handler("chat_deleted", self._on_chat_deleted)
|
||||
self._add_event_handler("profile_changed", self._on_profile_changed)
|
||||
# TODO many more listeners
|
||||
self._add_event_handler("disconnected", self._on_listen_disconnect)
|
||||
self._add_event_handler("switch_server", self._on_switch_server)
|
||||
|
@ -46,11 +46,13 @@ from .kt.types.chat.chat import Chatlog
|
||||
from .kt.types.client.client_session import LoginDataItem, LoginResult
|
||||
from .kt.types.oauth import OAuthCredential
|
||||
from .kt.types.openlink.open_channel_info import OpenChannelData, OpenChannelInfo
|
||||
from .kt.types.openlink.open_link_user_info import OpenLinkChannelUserInfo
|
||||
from .kt.types.packet.chat.kickout import KnownKickoutType, KickoutRes
|
||||
|
||||
METRIC_CONNECT_AND_SYNC = Summary("bridge_connect_and_sync", "calls to connect_and_sync")
|
||||
METRIC_CHAT = Summary("bridge_on_chat", "calls to on_chat")
|
||||
METRIC_CHAT_DELETED = Summary("bridge_on_chat_deleted", "calls to on_chat_deleted")
|
||||
METRIC_PROFILE_CHANGE = Summary("bridge_on_profile_changed", "calls to on_profile_changed")
|
||||
METRIC_LOGGED_IN = Gauge("bridge_logged_in", "Users logged into the bridge")
|
||||
METRIC_CONNECTED = Gauge("bridge_connected", "Bridge users connected to KakaoTalk")
|
||||
|
||||
@ -701,6 +703,12 @@ class User(DBUser, BaseUser):
|
||||
puppet = await pu.Puppet.get_by_ktid(sender_id)
|
||||
await portal.handle_kakaotalk_chat_delete(puppet, chat_id, timestamp)
|
||||
|
||||
@async_time(METRIC_PROFILE_CHANGE)
|
||||
async def on_profile_changed(self, info: OpenLinkChannelUserInfo) -> None:
|
||||
puppet = await pu.Puppet.get_by_ktid(info.userId)
|
||||
if puppet:
|
||||
await puppet.update_info_from_participant(self, info)
|
||||
|
||||
# TODO Many more handlers
|
||||
|
||||
# endregion
|
||||
|
@ -121,6 +121,17 @@ class UserClient {
|
||||
})
|
||||
*/
|
||||
|
||||
this.#talkClient.on("profile_changed", (channel, lastInfo, user) => {
|
||||
this.log(`Profile of ${user.userId} changed (channel: ${channel})`)
|
||||
return this.write("profile_changed", {
|
||||
info: user,
|
||||
/* TODO Is this ever a per-channel profile change?
|
||||
channelId: channel.channelId,
|
||||
channelType: channel.info.type,
|
||||
*/
|
||||
})
|
||||
})
|
||||
|
||||
this.#talkClient.on("disconnected", (reason) => {
|
||||
this.log(`Disconnected (reason=${reason})`)
|
||||
this.disconnect()
|
||||
|
Loading…
Reference in New Issue
Block a user