aykutalparslan / Ferrite

Experimental Telegram Server
GNU Affero General Public License v3.0
158 stars 25 forks source link

Add support for TL Conditional fields #142

Closed aykutalparslan closed 2 years ago

aykutalparslan commented 2 years ago

The construction

args ::= var-ident-opt : [ conditional-arg-def ] [ ! ] type-term
conditional-arg-def ::= var-ident [ . nat-const ] ?

permits assigning fields which are only present if the value of a preceding mandatory or optional field of type # is not null (or if its chosen bit is not zero if the special binary bit-selection operator . is applied). Example:

user {fields:#} id:int first_name:(fields.0?string) last_name:(fields.1?string) friends:(fields.2?%(Vector int)) = User fields;
get_users req_fields:# ids:%(Vector int) = Vector %(User req_fields)