Skip to content

Commit

Permalink
Convert int64 type to Dart string
Browse files Browse the repository at this point in the history
For some reason, int64 is returned as string from the Telegram server.
Adjust the generator to generate string type for int64 fields.

This fixes i-Naji#15.
  • Loading branch information
owenthereal committed Aug 26, 2020
1 parent 4f2f9fa commit 03ca1ba
Show file tree
Hide file tree
Showing 49 changed files with 64 additions and 61 deletions.
3 changes: 2 additions & 1 deletion generator/generate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,10 @@ class TlObjectArg {
case 'int':
case 'int32':
case 'int53':
case 'int64':
case 'long':
return 'int';
case 'int64':
return 'String';
case 'double':
return 'double';
case 'string':
Expand Down
2 changes: 2 additions & 0 deletions lib/src/tdapi/convertor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ part of 'tdapi.dart';
TdObject convertToObject(String query) {
if (query != null) {
final newJson = json.decode(query);
print("convertToObject");
print(newJson);
final object = allObjects[newJson['@type']](newJson);
return object;
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/answer_callback_query.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class AnswerCallbackQuery extends TdFunction {
int callbackQueryId;
String callbackQueryId;
String text;
bool showAlert;
String url;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/answer_custom_query.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class AnswerCustomQuery extends TdFunction {
int customQueryId;
String customQueryId;
String data;
dynamic extra;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/answer_inline_query.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class AnswerInlineQuery extends TdFunction {
int inlineQueryId;
String inlineQueryId;
bool isPersonal;
List<InputInlineQueryResult> results;
int cacheTime;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/answer_pre_checkout_query.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class AnswerPreCheckoutQuery extends TdFunction {
int preCheckoutQueryId;
String preCheckoutQueryId;
String errorMessage;
dynamic extra;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/answer_shipping_query.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class AnswerShippingQuery extends TdFunction {
int shippingQueryId;
String shippingQueryId;
List<ShippingOption> shippingOptions;
String errorMessage;
dynamic extra;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/change_sticker_set.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class ChangeStickerSet extends TdFunction {
int setId;
String setId;
bool isInstalled;
bool isArchived;
dynamic extra;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/delete_profile_photo.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class DeleteProfilePhoto extends TdFunction {
int profilePhotoId;
String profilePhotoId;
dynamic extra;

/// Deletes a profile photo.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/discard_call.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class DiscardCall extends TdFunction {
int callId;
bool isDisconnected;
int duration;
int connectionId;
String connectionId;
dynamic extra;

/// Discards a call.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/disconnect_website.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class DisconnectWebsite extends TdFunction {
int websiteId;
String websiteId;
dynamic extra;

/// Disconnects website from the current user's Telegram account.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/finish_file_generation.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class FinishFileGeneration extends TdFunction {
int generationId;
String generationId;
TdError error;
dynamic extra;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/get_archived_sticker_sets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ part of '../tdapi.dart';

class GetArchivedStickerSets extends TdFunction {
bool isMasks;
int offsetStickerSetId;
String offsetStickerSetId;
int limit;
dynamic extra;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/get_chat_event_log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ part of '../tdapi.dart';
class GetChatEventLog extends TdFunction {
int chatId;
String query;
int fromEventId;
String fromEventId;
int limit;
ChatEventLogFilters filters;
List<int> userIds;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/get_chats.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ part of '../tdapi.dart';

class GetChats extends TdFunction {
ChatList chatList;
int offsetOrder;
String offsetOrder;
int offsetChatId;
int limit;
dynamic extra;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/get_sticker_set.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class GetStickerSet extends TdFunction {
int setId;
String setId;
dynamic extra;

/// Returns information about a sticker set by its identifier.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/remove_background.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class RemoveBackground extends TdFunction {
int backgroundId;
String backgroundId;
dynamic extra;

/// Removes background from the list of installed backgrounds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ part of '../tdapi.dart';

class ReorderInstalledStickerSets extends TdFunction {
bool isMasks;
List<int> stickerSetIds;
List<String> stickerSetIds;
dynamic extra;

/// Changes the order of installed sticker sets.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/search_secret_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ part of '../tdapi.dart';
class SearchSecretMessages extends TdFunction {
int chatId;
String query;
int fromSearchId;
String fromSearchId;
int limit;
SearchMessagesFilter filter;
dynamic extra;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class SendInlineQueryResultMessage extends TdFunction {
int chatId;
int replyToMessageId;
SendMessageOptions options;
int queryId;
String queryId;
String resultId;
bool hideViaBot;
dynamic extra;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/set_file_generation_progress.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class SetFileGenerationProgress extends TdFunction {
int generationId;
String generationId;
int expectedSize;
int localPrefixSize;
dynamic extra;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/set_supergroup_sticker_set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ part of '../tdapi.dart';

class SetSupergroupStickerSet extends TdFunction {
int supergroupId;
int stickerSetId;
String stickerSetId;
dynamic extra;

/// Changes the sticker set of a supergroup; requires can_change_info rights.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/terminate_session.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class TerminateSession extends TdFunction {
int sessionId;
String sessionId;
dynamic extra;

/// Terminates a session of the current user.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/view_trending_sticker_sets.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class ViewTrendingStickerSets extends TdFunction {
List<int> stickerSetIds;
List<String> stickerSetIds;
dynamic extra;

/// Informs the server that some trending sticker sets have been viewed by the user.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/functions/write_generated_file_part.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class WriteGeneratedFilePart extends TdFunction {
int generationId;
String generationId;
int offset;
String data;
dynamic extra;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/background.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class Background extends TdObject {
int id;
String id;
bool isDefault;
bool isDark;
String name;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/call_connection.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class CallConnection extends TdObject {
int id;
String id;
String ip;
String ipv6;
int port;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/chat_event.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class ChatEvent extends TdObject {
int id;
String id;
int date;
int userId;
ChatEventAction action;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/tdapi/objects/chat_event_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,8 @@ class ChatEventSignMessagesToggled extends ChatEventAction {
}

class ChatEventStickerSetChanged extends ChatEventAction {
int oldStickerSetId;
int newStickerSetId;
String oldStickerSetId;
String newStickerSetId;

/// The supergroup sticker set was changed.
/// [oldStickerSetId] Previous identifier of the chat sticker set; 0 if none .
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/chat_photo.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class ChatPhoto extends TdObject {
int id;
String id;
int addedDate;
Minithumbnail minithumbnail;
List<PhotoSize> sizes;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/chat_position.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ part of '../tdapi.dart';

class ChatPosition extends TdObject {
ChatList list;
int order;
String order;
bool isPinned;
ChatSource source;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/connected_website.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class ConnectedWebsite extends TdObject {
int id;
String id;
String domainName;
int botUserId;
String browser;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/found_messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ part of '../tdapi.dart';

class FoundMessages extends TdObject {
List<Message> messages;
int nextFromSearchId;
String nextFromSearchId;
dynamic extra;

/// Contains a list of messages found by a search.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/game.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class Game extends TdObject {
int id;
String id;
String shortName;
String title;
FormattedText text;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/inline_query_results.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class InlineQueryResults extends TdObject {
int inlineQueryId;
String inlineQueryId;
String nextOffset;
List<InlineQueryResult> results;
String switchPmText;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/input_background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class InputBackgroundLocal extends InputBackground {
}

class InputBackgroundRemote extends InputBackground {
int backgroundId;
String backgroundId;

/// A background from the server.
/// [backgroundId] The background identifier
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/input_chat_photo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class InputChatPhoto extends TdObject {
}

class InputChatPhotoPrevious extends InputChatPhoto {
int chatPhotoId;
String chatPhotoId;

/// A previously used profile photo of the current user.
/// [chatPhotoId] Identifier of the profile photo to reuse
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Message extends TdObject {
int viaBotUserId;
String authorSignature;
int views;
int mediaAlbumId;
String mediaAlbumId;
String restrictionReason;
MessageContent content;
ReplyMarkup replyMarkup;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/message_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ class MessageCustomServiceAction extends MessageContent {

class MessageGameScore extends MessageContent {
int gameMessageId;
int gameId;
String gameId;
int score;

/// A new high score was achieved in a game.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/poll.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class Poll extends TdObject {
int id;
String id;
String question;
List<PollOption> options;
int totalVoterCount;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/profile_photo.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class ProfilePhoto extends TdObject {
int id;
String id;
File small;
File big;
bool hasAnimation;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/push_receiver_id.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class PushReceiverId extends TdObject {
int id;
String id;
dynamic extra;

/// Contains a globally unique push receiver identifier, which can be used to identify which account has received a push notification.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tdapi/objects/session.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of '../tdapi.dart';

class Session extends TdObject {
int id;
String id;
bool isCurrent;
bool isPasswordPending;
int apiId;
Expand Down

0 comments on commit 03ca1ba

Please sign in to comment.