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

Add _type to all Telegram API objects in ndjson #368

Merged

Conversation

ianroberts
Copy link
Contributor

Fixes #367

Currently when serializing Telegram TL schema objects to ndjson the _type tag (giving the type of the relevant API object) is only included in some places and is omitted in others, most notably when serializing a list of objects rather than a single one. This PR updates SearchTelegram.serialize_obj to include the _type tag in all cases, by adding it immediately before returning rather than making it a special case added only to certain child properties.

@ianroberts
Copy link
Contributor Author

Rebased on latest master

Previously SearchTelegram.serialize_obj would only add the "_type" tag to the JSON object representing a TLObject if that object was an immediate child property of another TLObject - other cases would not add the _type, in particular

- where a TLObject has a property whose value is a *list* of other TLObjects, the members of the list would not have a _type in the JSON - this is most noticeable for things like Message.entities, Page.blocks, etc.
- the initial object passed in to serialize_obj did not have a _type added
- 'if type(value).__module__[0:8] == "telethon"' is subsumed by 'if type(value) not in scalars and value is not None'
- 'if type(value) is dict' is unreachable since dict is not in scalars, so the loop will already have continue-d at the previous condition
@stijn-uva
Copy link
Member

Thanks!

@stijn-uva stijn-uva merged commit b3f0097 into digitalmethodsinitiative:master Aug 22, 2023
1 check passed
ianroberts added a commit to GateNLP/4cat that referenced this pull request Aug 22, 2023
@stijn-uva stijn-uva added this to the 1.37 milestone Oct 9, 2023
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

Successfully merging this pull request may close these issues.

Telegram ndjson missing types on nested lists
2 participants