diff --git a/fbchat/_client.py b/fbchat/_client.py index 3cbe7bd..ff2d043 100644 --- a/fbchat/_client.py +++ b/fbchat/_client.py @@ -186,10 +186,10 @@ class Client: users = [] users_to_fetch = [] # It's more efficient to fetch all users in one request for thread in threads: - if thread.type == ThreadType.USER: + if isinstance(thread, User): if thread.id not in [user.id for user in users]: users.append(thread) - elif thread.type == ThreadType.GROUP: + elif isinstance(thread, Group): for user_id in thread.participants: if ( user_id not in [user.id for user in users] @@ -458,7 +458,7 @@ class Client: threads = self.fetch_thread_info(*user_ids) users = {} for id_, thread in threads.items(): - if thread.type == ThreadType.USER: + if isinstance(thread, User): users[id_] = thread else: raise ValueError("Thread {} was not a user".format(thread)) @@ -483,7 +483,7 @@ class Client: threads = self.fetch_thread_info(*page_ids) pages = {} for id_, thread in threads.items(): - if thread.type == ThreadType.PAGE: + if isinstance(thread, Page): pages[id_] = thread else: raise ValueError("Thread {} was not a page".format(thread)) @@ -505,7 +505,7 @@ class Client: threads = self.fetch_thread_info(*group_ids) groups = {} for id_, thread in threads.items(): - if thread.type == ThreadType.GROUP: + if isinstance(thread, Group): groups[id_] = thread else: raise ValueError("Thread {} was not a group".format(thread)) diff --git a/fbchat/_group.py b/fbchat/_group.py index e418a44..d206259 100644 --- a/fbchat/_group.py +++ b/fbchat/_group.py @@ -1,7 +1,7 @@ import attr from ._core import attrs_default, Image from . import _util, _session, _plan -from ._thread import ThreadType, Thread +from ._thread import Thread from typing import Iterable @@ -9,8 +9,6 @@ from typing import Iterable class Group(Thread): """Represents a Facebook group. Inherits `Thread`.""" - type = ThreadType.GROUP - #: The session to use when making requests. session = attr.ib(type=_session.Session) #: The group's unique identifier. diff --git a/fbchat/_page.py b/fbchat/_page.py index b2601a4..9310df4 100644 --- a/fbchat/_page.py +++ b/fbchat/_page.py @@ -1,15 +1,13 @@ import attr from ._core import attrs_default, Image from . import _session, _plan -from ._thread import ThreadType, Thread +from ._thread import Thread @attrs_default class Page(Thread): """Represents a Facebook page. Inherits `Thread`.""" - type = ThreadType.PAGE - #: The session to use when making requests. session = attr.ib(type=_session.Session) #: The unique identifier of the page. diff --git a/fbchat/_thread.py b/fbchat/_thread.py index 7c3796e..643a979 100644 --- a/fbchat/_thread.py +++ b/fbchat/_thread.py @@ -76,8 +76,6 @@ class Thread: session = attr.ib(type=_session.Session) #: The unique identifier of the thread. id = attr.ib(converter=str) - #: Specifies the type of thread. Can be used a ``thread_type``. See :ref:`intro_threads` for more info - type = None @staticmethod def _parse_customization_info(data): diff --git a/fbchat/_user.py b/fbchat/_user.py index 1224fbe..93ea274 100644 --- a/fbchat/_user.py +++ b/fbchat/_user.py @@ -1,7 +1,7 @@ import attr from ._core import attrs_default, Enum, Image from . import _util, _session, _plan -from ._thread import ThreadType, Thread +from ._thread import Thread GENDERS = { @@ -45,8 +45,6 @@ class TypingStatus(Enum): class User(Thread): """Represents a Facebook user. Inherits `Thread`.""" - type = ThreadType.USER - #: The session to use when making requests. session = attr.ib(type=_session.Session) #: The user's unique identifier. diff --git a/tests/test_fetch.py b/tests/test_fetch.py index 59d222d..4ddd66a 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -89,7 +89,6 @@ def test_fetch_info(client1, group): assert info.name == "Mark Zuckerberg" info = client1.fetch_group_info(group["id"])[group["id"]] - assert info.type == ThreadType.GROUP def test_fetch_image_url(client): diff --git a/tests/test_search.py b/tests/test_search.py index ac59cfa..bd7b440 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -11,7 +11,6 @@ def test_search_for(client1): u = users[0] assert u.id == "4" - assert u.type == ThreadType.USER assert u.photo[:4] == "http" assert u.url[:4] == "http" assert u.name == "Mark Zuckerberg"