Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat Webpath objects are not being parsed properly #492

Open
vcapelca opened this issue Dec 9, 2021 · 0 comments
Open

Chat Webpath objects are not being parsed properly #492

vcapelca opened this issue Dec 9, 2021 · 0 comments

Comments

@vcapelca
Copy link

vcapelca commented Dec 9, 2021

Hi there! Thanks for creating this module, super helpful!

Today, though, there's been an issue when attempting to access the Chat Webpaths objects for some Chats. Basically, there's some chats where the Webpath list consists of a ProxyList rather than the usual Webpath object, which makes impossible to extract the different fields as used to:

>>> chat.webpath
[[1639008082, 'https://www.test.com', 'https://www.test.com', 'Test Title']]
>>> chat2.webpath
[Webpath(), Webpath()]
>>> [{'chat_id': chat.id, 'title': webpath.title} for webpath in chat.webpath]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <listcomp>
AttributeError: 'ProxyList' object has no attribute 'title'
>>> [{'chat_id': chat.id, 'title': webpath.title} for webpath in chat2.webpath]
[{'chat_id': '12345', 'title': 'Test Title'}, {'chat_id': '67890', 'title': 'Test Title'}]

I've applied a workaround to process these cases, assuming that the fields in the ProxyList always come in the same format:

if isinstance(webpath, Webpath)
            else {
                "chat_id": chat.id,
                "title": webpath[3],
                "to": webpath[1],
                "from": webpath[2],
                "timestamp": webpath[0],
            }

But thought it was worth sharing with you folks so a proper fix can be applied here, since the patch is quite hacky and I'd be expecting Webpath objects there, which seems to be something wrong when building the object on Zenpy side.

Best regards,
Víctor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant