From a36ff5ee6e5c7b1c29593cc7a05e36b3ea38d9d6 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 8 Jan 2020 12:24:47 +0100 Subject: [PATCH] Make Session.user_id readonly --- fbchat/_session.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fbchat/_session.py b/fbchat/_session.py index aa86a7c..7222d7b 100644 --- a/fbchat/_session.py +++ b/fbchat/_session.py @@ -105,7 +105,7 @@ class Session: This is the main class, which is used to login to Facebook. """ - user_id = attr.ib() + _user_id = attr.ib() _fb_dtsg = attr.ib() _revision = attr.ib() _session = attr.ib(factory=session_factory) @@ -113,6 +113,11 @@ class Session: _client_id = attr.ib(factory=client_id_factory) _logout_h = attr.ib(None) + @property + def user_id(self): + """The logged in user's ID.""" + return self._user_id + def _get_params(self): self._counter += 1 # TODO: Make this operation atomic / thread-safe return { @@ -308,7 +313,7 @@ class Session: def _do_send_request(self, data): offline_threading_id = _util.generate_offline_threading_id() data["client"] = "mercury" - data["author"] = "fbid:{}".format(self.user_id) + data["author"] = "fbid:{}".format(self._user_id) data["timestamp"] = _util.now() data["source"] = "source:chat:web" data["offline_threading_id"] = offline_threading_id