From 1011dc13aed7f1abf2c928c71a26af0f9cb35ae6 Mon Sep 17 00:00:00 2001 From: c0re100 Date: Mon, 9 May 2022 19:35:19 +0800 Subject: [PATCH] Update to TDLib master --- client/function.go | 33 ++- client/type.go | 513 +++++++++++++++++++++++++++++++++++++++++- client/unmarshaler.go | 266 ++++++++++++++++++++++ data/td_api.tl | 72 +++++- 4 files changed, 871 insertions(+), 13 deletions(-) diff --git a/client/function.go b/client/function.go index fd68971..055e5c9 100755 --- a/client/function.go +++ b/client/function.go @@ -8098,7 +8098,7 @@ type SendCallDebugInformationRequest struct { DebugInformation string `json:"debug_information"` } -// Sends debug information for a call +// Sends debug information for a call to Telegram servers func (client *Client) SendCallDebugInformation(req *SendCallDebugInformationRequest) (*Ok, error) { result, err := client.Send(Request{ meta: meta{ @@ -8120,6 +8120,35 @@ func (client *Client) SendCallDebugInformation(req *SendCallDebugInformationRequ return UnmarshalOk(result.Data) } +type SendCallLogRequest struct { + // Call identifier + CallId int32 `json:"call_id"` + // Call log file. Only inputFileLocal and inputFileGenerated are supported + LogFile InputFile `json:"log_file"` +} + +// Sends log file for a call to Telegram servers +func (client *Client) SendCallLog(req *SendCallLogRequest) (*Ok, error) { + result, err := client.Send(Request{ + meta: meta{ + Type: "sendCallLog", + }, + Data: map[string]interface{}{ + "call_id": req.CallId, + "log_file": req.LogFile, + }, + }) + if err != nil { + return nil, err + } + + if result.Type == "error" { + return nil, buildResponseError(result.Data) + } + + return UnmarshalOk(result.Data) +} + type GetVideoChatAvailableParticipantsRequest struct { // Chat identifier ChatId int64 `json:"chat_id"` @@ -9299,7 +9328,7 @@ type SearchUserByPhoneNumberRequest struct { PhoneNumber string `json:"phone_number"` } -// Searches a user by their phone number +// Searches a user by their phone number. Returns a 404 error if the user can't be found func (client *Client) SearchUserByPhoneNumber(req *SearchUserByPhoneNumberRequest) (*User, error) { result, err := client.Send(Request{ meta: meta{ diff --git a/client/type.go b/client/type.go index a37059e..9103bfb 100755 --- a/client/type.go +++ b/client/type.go @@ -77,6 +77,7 @@ const ( ClassJsonValue = "JsonValue" ClassUserPrivacySettingRule = "UserPrivacySettingRule" ClassUserPrivacySetting = "UserPrivacySetting" + ClassSessionType = "SessionType" ClassChatReportReason = "ChatReportReason" ClassInternalLinkType = "InternalLinkType" ClassFileType = "FileType" @@ -1088,6 +1089,23 @@ const ( TypeUserPrivacySettingAllowPeerToPeerCalls = "userPrivacySettingAllowPeerToPeerCalls" TypeUserPrivacySettingAllowFindingByPhoneNumber = "userPrivacySettingAllowFindingByPhoneNumber" TypeAccountTtl = "accountTtl" + TypeSessionTypeAndroid = "sessionTypeAndroid" + TypeSessionTypeApple = "sessionTypeApple" + TypeSessionTypeBrave = "sessionTypeBrave" + TypeSessionTypeChrome = "sessionTypeChrome" + TypeSessionTypeEdge = "sessionTypeEdge" + TypeSessionTypeFirefox = "sessionTypeFirefox" + TypeSessionTypeIpad = "sessionTypeIpad" + TypeSessionTypeIphone = "sessionTypeIphone" + TypeSessionTypeLinux = "sessionTypeLinux" + TypeSessionTypeMac = "sessionTypeMac" + TypeSessionTypeOpera = "sessionTypeOpera" + TypeSessionTypeSafari = "sessionTypeSafari" + TypeSessionTypeUbuntu = "sessionTypeUbuntu" + TypeSessionTypeUnknown = "sessionTypeUnknown" + TypeSessionTypeVivaldi = "sessionTypeVivaldi" + TypeSessionTypeWindows = "sessionTypeWindows" + TypeSessionTypeXbox = "sessionTypeXbox" TypeSession = "session" TypeSessions = "sessions" TypeConnectedWebsite = "connectedWebsite" @@ -1692,6 +1710,11 @@ type UserPrivacySetting interface { UserPrivacySettingType() string } +// Represents the type of a session +type SessionType interface { + SessionTypeType() string +} + // Describes the reason why a chat is reported type ChatReportReason interface { ChatReportReasonType() string @@ -18907,6 +18930,8 @@ type CallStateDiscarded struct { NeedRating bool `json:"need_rating"` // True, if the call debug information must be sent to the server NeedDebugInformation bool `json:"need_debug_information"` + // True, if the call log must be sent to the server + NeedLog bool `json:"need_log"` } func (entity *CallStateDiscarded) MarshalJSON() ([]byte, error) { @@ -18934,6 +18959,7 @@ func (callStateDiscarded *CallStateDiscarded) UnmarshalJSON(data []byte) error { Reason json.RawMessage `json:"reason"` NeedRating bool `json:"need_rating"` NeedDebugInformation bool `json:"need_debug_information"` + NeedLog bool `json:"need_log"` } err := json.Unmarshal(data, &tmp) @@ -18943,6 +18969,7 @@ func (callStateDiscarded *CallStateDiscarded) UnmarshalJSON(data []byte) error { callStateDiscarded.NeedRating = tmp.NeedRating callStateDiscarded.NeedDebugInformation = tmp.NeedDebugInformation + callStateDiscarded.NeedLog = tmp.NeedLog fieldReason, _ := UnmarshalCallDiscardReason(tmp.Reason) callStateDiscarded.Reason = fieldReason @@ -25381,8 +25408,8 @@ type Notification struct { Id int32 `json:"id"` // Notification date Date int32 `json:"date"` - // Identifier of the notification sound to be played; 0 if sound is disabled - SoundId JsonInt64 `json:"sound_id"` + // True, if the notification was explicitly sent without sound + IsSilent bool `json:"is_silent"` // Notification type Type NotificationType `json:"type"` } @@ -25407,7 +25434,7 @@ func (notification *Notification) UnmarshalJSON(data []byte) error { var tmp struct { Id int32 `json:"id"` Date int32 `json:"date"` - SoundId JsonInt64 `json:"sound_id"` + IsSilent bool `json:"is_silent"` Type json.RawMessage `json:"type"` } @@ -25418,7 +25445,7 @@ func (notification *Notification) UnmarshalJSON(data []byte) error { notification.Id = tmp.Id notification.Date = tmp.Date - notification.SoundId = tmp.SoundId + notification.IsSilent = tmp.IsSilent fieldType, _ := UnmarshalNotificationType(tmp.Type) notification.Type = fieldType @@ -26278,6 +26305,431 @@ func (*AccountTtl) GetType() string { return TypeAccountTtl } +// The session is running on an Android device +type SessionTypeAndroid struct{ + meta +} + +func (entity *SessionTypeAndroid) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeAndroid + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeAndroid) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeAndroid) GetType() string { + return TypeSessionTypeAndroid +} + +func (*SessionTypeAndroid) SessionTypeType() string { + return TypeSessionTypeAndroid +} + +// The session is running on a generic Apple device +type SessionTypeApple struct{ + meta +} + +func (entity *SessionTypeApple) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeApple + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeApple) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeApple) GetType() string { + return TypeSessionTypeApple +} + +func (*SessionTypeApple) SessionTypeType() string { + return TypeSessionTypeApple +} + +// The session is running on the Brave browser +type SessionTypeBrave struct{ + meta +} + +func (entity *SessionTypeBrave) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeBrave + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeBrave) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeBrave) GetType() string { + return TypeSessionTypeBrave +} + +func (*SessionTypeBrave) SessionTypeType() string { + return TypeSessionTypeBrave +} + +// The session is running on the Chrome browser +type SessionTypeChrome struct{ + meta +} + +func (entity *SessionTypeChrome) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeChrome + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeChrome) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeChrome) GetType() string { + return TypeSessionTypeChrome +} + +func (*SessionTypeChrome) SessionTypeType() string { + return TypeSessionTypeChrome +} + +// The session is running on the Edge browser +type SessionTypeEdge struct{ + meta +} + +func (entity *SessionTypeEdge) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeEdge + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeEdge) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeEdge) GetType() string { + return TypeSessionTypeEdge +} + +func (*SessionTypeEdge) SessionTypeType() string { + return TypeSessionTypeEdge +} + +// The session is running on the Firefox browser +type SessionTypeFirefox struct{ + meta +} + +func (entity *SessionTypeFirefox) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeFirefox + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeFirefox) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeFirefox) GetType() string { + return TypeSessionTypeFirefox +} + +func (*SessionTypeFirefox) SessionTypeType() string { + return TypeSessionTypeFirefox +} + +// The session is running on an iPad device +type SessionTypeIpad struct{ + meta +} + +func (entity *SessionTypeIpad) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeIpad + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeIpad) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeIpad) GetType() string { + return TypeSessionTypeIpad +} + +func (*SessionTypeIpad) SessionTypeType() string { + return TypeSessionTypeIpad +} + +// The session is running on an iPhone device +type SessionTypeIphone struct{ + meta +} + +func (entity *SessionTypeIphone) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeIphone + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeIphone) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeIphone) GetType() string { + return TypeSessionTypeIphone +} + +func (*SessionTypeIphone) SessionTypeType() string { + return TypeSessionTypeIphone +} + +// The session is running on a Linux device +type SessionTypeLinux struct{ + meta +} + +func (entity *SessionTypeLinux) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeLinux + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeLinux) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeLinux) GetType() string { + return TypeSessionTypeLinux +} + +func (*SessionTypeLinux) SessionTypeType() string { + return TypeSessionTypeLinux +} + +// The session is running on a Mac device +type SessionTypeMac struct{ + meta +} + +func (entity *SessionTypeMac) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeMac + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeMac) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeMac) GetType() string { + return TypeSessionTypeMac +} + +func (*SessionTypeMac) SessionTypeType() string { + return TypeSessionTypeMac +} + +// The session is running on the Opera browser +type SessionTypeOpera struct{ + meta +} + +func (entity *SessionTypeOpera) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeOpera + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeOpera) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeOpera) GetType() string { + return TypeSessionTypeOpera +} + +func (*SessionTypeOpera) SessionTypeType() string { + return TypeSessionTypeOpera +} + +// The session is running on the Safari browser +type SessionTypeSafari struct{ + meta +} + +func (entity *SessionTypeSafari) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeSafari + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeSafari) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeSafari) GetType() string { + return TypeSessionTypeSafari +} + +func (*SessionTypeSafari) SessionTypeType() string { + return TypeSessionTypeSafari +} + +// The session is running on an Ubuntu device +type SessionTypeUbuntu struct{ + meta +} + +func (entity *SessionTypeUbuntu) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeUbuntu + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeUbuntu) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeUbuntu) GetType() string { + return TypeSessionTypeUbuntu +} + +func (*SessionTypeUbuntu) SessionTypeType() string { + return TypeSessionTypeUbuntu +} + +// The session is running on an unknown type of device +type SessionTypeUnknown struct{ + meta +} + +func (entity *SessionTypeUnknown) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeUnknown + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeUnknown) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeUnknown) GetType() string { + return TypeSessionTypeUnknown +} + +func (*SessionTypeUnknown) SessionTypeType() string { + return TypeSessionTypeUnknown +} + +// The session is running on the Vivaldi browser +type SessionTypeVivaldi struct{ + meta +} + +func (entity *SessionTypeVivaldi) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeVivaldi + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeVivaldi) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeVivaldi) GetType() string { + return TypeSessionTypeVivaldi +} + +func (*SessionTypeVivaldi) SessionTypeType() string { + return TypeSessionTypeVivaldi +} + +// The session is running on a Windows device +type SessionTypeWindows struct{ + meta +} + +func (entity *SessionTypeWindows) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeWindows + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeWindows) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeWindows) GetType() string { + return TypeSessionTypeWindows +} + +func (*SessionTypeWindows) SessionTypeType() string { + return TypeSessionTypeWindows +} + +// The session is running on an Xbox console +type SessionTypeXbox struct{ + meta +} + +func (entity *SessionTypeXbox) MarshalJSON() ([]byte, error) { + entity.meta.Type = entity.GetType() + + type stub SessionTypeXbox + + return json.Marshal((*stub)(entity)) +} + +func (*SessionTypeXbox) GetClass() string { + return ClassSessionType +} + +func (*SessionTypeXbox) GetType() string { + return TypeSessionTypeXbox +} + +func (*SessionTypeXbox) SessionTypeType() string { + return TypeSessionTypeXbox +} + // Contains information about one session in a Telegram application used by the current user. Sessions must be shown to the user in the returned order type Session struct { meta @@ -26291,6 +26743,8 @@ type Session struct { CanAcceptSecretChats bool `json:"can_accept_secret_chats"` // True, if incoming calls can be accepted by the session CanAcceptCalls bool `json:"can_accept_calls"` + // Session type based on the system and application version, which can be used to display a corresponding icon + Type SessionType `json:"type"` // Telegram API identifier, as provided by the application ApiId int32 `json:"api_id"` // Name of the application, as provided by the application @@ -26333,6 +26787,57 @@ func (*Session) GetType() string { return TypeSession } +func (session *Session) UnmarshalJSON(data []byte) error { + var tmp struct { + Id JsonInt64 `json:"id"` + IsCurrent bool `json:"is_current"` + IsPasswordPending bool `json:"is_password_pending"` + CanAcceptSecretChats bool `json:"can_accept_secret_chats"` + CanAcceptCalls bool `json:"can_accept_calls"` + Type json.RawMessage `json:"type"` + ApiId int32 `json:"api_id"` + ApplicationName string `json:"application_name"` + ApplicationVersion string `json:"application_version"` + IsOfficialApplication bool `json:"is_official_application"` + DeviceModel string `json:"device_model"` + Platform string `json:"platform"` + SystemVersion string `json:"system_version"` + LogInDate int32 `json:"log_in_date"` + LastActiveDate int32 `json:"last_active_date"` + Ip string `json:"ip"` + Country string `json:"country"` + Region string `json:"region"` + } + + err := json.Unmarshal(data, &tmp) + if err != nil { + return err + } + + session.Id = tmp.Id + session.IsCurrent = tmp.IsCurrent + session.IsPasswordPending = tmp.IsPasswordPending + session.CanAcceptSecretChats = tmp.CanAcceptSecretChats + session.CanAcceptCalls = tmp.CanAcceptCalls + session.ApiId = tmp.ApiId + session.ApplicationName = tmp.ApplicationName + session.ApplicationVersion = tmp.ApplicationVersion + session.IsOfficialApplication = tmp.IsOfficialApplication + session.DeviceModel = tmp.DeviceModel + session.Platform = tmp.Platform + session.SystemVersion = tmp.SystemVersion + session.LogInDate = tmp.LogInDate + session.LastActiveDate = tmp.LastActiveDate + session.Ip = tmp.Ip + session.Country = tmp.Country + session.Region = tmp.Region + + fieldType, _ := UnmarshalSessionType(tmp.Type) + session.Type = fieldType + + return nil +} + // Contains a list of sessions type Sessions struct { meta diff --git a/client/unmarshaler.go b/client/unmarshaler.go index f1add86..078b79f 100755 --- a/client/unmarshaler.go +++ b/client/unmarshaler.go @@ -3614,6 +3614,85 @@ func UnmarshalListOfUserPrivacySetting(dataList []json.RawMessage) ([]UserPrivac return list, nil } +func UnmarshalSessionType(data json.RawMessage) (SessionType, error) { + var meta meta + + err := json.Unmarshal(data, &meta) + if err != nil { + return nil, err + } + + switch meta.Type { + case TypeSessionTypeAndroid: + return UnmarshalSessionTypeAndroid(data) + + case TypeSessionTypeApple: + return UnmarshalSessionTypeApple(data) + + case TypeSessionTypeBrave: + return UnmarshalSessionTypeBrave(data) + + case TypeSessionTypeChrome: + return UnmarshalSessionTypeChrome(data) + + case TypeSessionTypeEdge: + return UnmarshalSessionTypeEdge(data) + + case TypeSessionTypeFirefox: + return UnmarshalSessionTypeFirefox(data) + + case TypeSessionTypeIpad: + return UnmarshalSessionTypeIpad(data) + + case TypeSessionTypeIphone: + return UnmarshalSessionTypeIphone(data) + + case TypeSessionTypeLinux: + return UnmarshalSessionTypeLinux(data) + + case TypeSessionTypeMac: + return UnmarshalSessionTypeMac(data) + + case TypeSessionTypeOpera: + return UnmarshalSessionTypeOpera(data) + + case TypeSessionTypeSafari: + return UnmarshalSessionTypeSafari(data) + + case TypeSessionTypeUbuntu: + return UnmarshalSessionTypeUbuntu(data) + + case TypeSessionTypeUnknown: + return UnmarshalSessionTypeUnknown(data) + + case TypeSessionTypeVivaldi: + return UnmarshalSessionTypeVivaldi(data) + + case TypeSessionTypeWindows: + return UnmarshalSessionTypeWindows(data) + + case TypeSessionTypeXbox: + return UnmarshalSessionTypeXbox(data) + + default: + return nil, fmt.Errorf("Error unmarshaling. Unknown type: " + meta.Type) + } +} + +func UnmarshalListOfSessionType(dataList []json.RawMessage) ([]SessionType, error) { + list := []SessionType{} + + for _, data := range dataList { + entity, err := UnmarshalSessionType(data) + if err != nil { + return nil, err + } + list = append(list, entity) + } + + return list, nil +} + func UnmarshalChatReportReason(data json.RawMessage) (ChatReportReason, error) { var meta meta @@ -10712,6 +10791,142 @@ func UnmarshalAccountTtl(data json.RawMessage) (*AccountTtl, error) { return &resp, err } +func UnmarshalSessionTypeAndroid(data json.RawMessage) (*SessionTypeAndroid, error) { + var resp SessionTypeAndroid + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeApple(data json.RawMessage) (*SessionTypeApple, error) { + var resp SessionTypeApple + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeBrave(data json.RawMessage) (*SessionTypeBrave, error) { + var resp SessionTypeBrave + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeChrome(data json.RawMessage) (*SessionTypeChrome, error) { + var resp SessionTypeChrome + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeEdge(data json.RawMessage) (*SessionTypeEdge, error) { + var resp SessionTypeEdge + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeFirefox(data json.RawMessage) (*SessionTypeFirefox, error) { + var resp SessionTypeFirefox + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeIpad(data json.RawMessage) (*SessionTypeIpad, error) { + var resp SessionTypeIpad + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeIphone(data json.RawMessage) (*SessionTypeIphone, error) { + var resp SessionTypeIphone + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeLinux(data json.RawMessage) (*SessionTypeLinux, error) { + var resp SessionTypeLinux + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeMac(data json.RawMessage) (*SessionTypeMac, error) { + var resp SessionTypeMac + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeOpera(data json.RawMessage) (*SessionTypeOpera, error) { + var resp SessionTypeOpera + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeSafari(data json.RawMessage) (*SessionTypeSafari, error) { + var resp SessionTypeSafari + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeUbuntu(data json.RawMessage) (*SessionTypeUbuntu, error) { + var resp SessionTypeUbuntu + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeUnknown(data json.RawMessage) (*SessionTypeUnknown, error) { + var resp SessionTypeUnknown + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeVivaldi(data json.RawMessage) (*SessionTypeVivaldi, error) { + var resp SessionTypeVivaldi + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeWindows(data json.RawMessage) (*SessionTypeWindows, error) { + var resp SessionTypeWindows + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + +func UnmarshalSessionTypeXbox(data json.RawMessage) (*SessionTypeXbox, error) { + var resp SessionTypeXbox + + err := json.Unmarshal(data, &resp) + + return &resp, err +} + func UnmarshalSession(data json.RawMessage) (*Session, error) { var resp Session @@ -14984,6 +15199,57 @@ func UnmarshalType(data json.RawMessage) (Type, error) { case TypeAccountTtl: return UnmarshalAccountTtl(data) + case TypeSessionTypeAndroid: + return UnmarshalSessionTypeAndroid(data) + + case TypeSessionTypeApple: + return UnmarshalSessionTypeApple(data) + + case TypeSessionTypeBrave: + return UnmarshalSessionTypeBrave(data) + + case TypeSessionTypeChrome: + return UnmarshalSessionTypeChrome(data) + + case TypeSessionTypeEdge: + return UnmarshalSessionTypeEdge(data) + + case TypeSessionTypeFirefox: + return UnmarshalSessionTypeFirefox(data) + + case TypeSessionTypeIpad: + return UnmarshalSessionTypeIpad(data) + + case TypeSessionTypeIphone: + return UnmarshalSessionTypeIphone(data) + + case TypeSessionTypeLinux: + return UnmarshalSessionTypeLinux(data) + + case TypeSessionTypeMac: + return UnmarshalSessionTypeMac(data) + + case TypeSessionTypeOpera: + return UnmarshalSessionTypeOpera(data) + + case TypeSessionTypeSafari: + return UnmarshalSessionTypeSafari(data) + + case TypeSessionTypeUbuntu: + return UnmarshalSessionTypeUbuntu(data) + + case TypeSessionTypeUnknown: + return UnmarshalSessionTypeUnknown(data) + + case TypeSessionTypeVivaldi: + return UnmarshalSessionTypeVivaldi(data) + + case TypeSessionTypeWindows: + return UnmarshalSessionTypeWindows(data) + + case TypeSessionTypeXbox: + return UnmarshalSessionTypeXbox(data) + case TypeSession: return UnmarshalSession(data) diff --git a/data/td_api.tl b/data/td_api.tl index c4479ec..f36e748 100644 --- a/data/td_api.tl +++ b/data/td_api.tl @@ -2346,8 +2346,8 @@ callStateReady protocol:callProtocol servers:vector config:string en //@description The call is hanging up after discardCall has been called callStateHangingUp = CallState; -//@description The call has ended successfully @reason The reason, why the call has ended @need_rating True, if the call rating must be sent to the server @need_debug_information True, if the call debug information must be sent to the server -callStateDiscarded reason:CallDiscardReason need_rating:Bool need_debug_information:Bool = CallState; +//@description The call has ended successfully @reason The reason, why the call has ended @need_rating True, if the call rating must be sent to the server @need_debug_information True, if the call debug information must be sent to the server @need_log True, if the call log must be sent to the server +callStateDiscarded reason:CallDiscardReason need_rating:Bool need_debug_information:Bool need_log:Bool = CallState; //@description The call has ended with an error @error Error. An error with the code 4005000 will be returned if an outgoing call is missed because of an expired timeout callStateError error:error = CallState; @@ -3180,8 +3180,8 @@ notificationSounds notification_sounds:vector = NotificationS //@description Contains information about a notification @id Unique persistent identifier of this notification @date Notification date -//@sound_id Identifier of the notification sound to be played; 0 if sound is disabled @type Notification type -notification id:int32 date:int32 sound_id:int64 type:NotificationType = Notification; +//@is_silent True, if the notification was explicitly sent without sound @type Notification type +notification id:int32 date:int32 is_silent:Bool type:NotificationType = Notification; //@description Describes a group of notifications @id Unique persistent auto-incremented from 1 identifier of the notification group @type Type of the group //@chat_id Identifier of a chat to which all notifications in the group belong @@ -3288,18 +3288,73 @@ userPrivacySettingAllowFindingByPhoneNumber = UserPrivacySetting; accountTtl days:int32 = AccountTtl; +//@class SessionType @description Represents the type of a session + +//@description The session is running on an Android device +sessionTypeAndroid = SessionType; + +//@description The session is running on a generic Apple device +sessionTypeApple = SessionType; + +//@description The session is running on the Brave browser +sessionTypeBrave = SessionType; + +//@description The session is running on the Chrome browser +sessionTypeChrome = SessionType; + +//@description The session is running on the Edge browser +sessionTypeEdge = SessionType; + +//@description The session is running on the Firefox browser +sessionTypeFirefox = SessionType; + +//@description The session is running on an iPad device +sessionTypeIpad = SessionType; + +//@description The session is running on an iPhone device +sessionTypeIphone = SessionType; + +//@description The session is running on a Linux device +sessionTypeLinux = SessionType; + +//@description The session is running on a Mac device +sessionTypeMac = SessionType; + +//@description The session is running on the Opera browser +sessionTypeOpera = SessionType; + +//@description The session is running on the Safari browser +sessionTypeSafari = SessionType; + +//@description The session is running on an Ubuntu device +sessionTypeUbuntu = SessionType; + +//@description The session is running on an unknown type of device +sessionTypeUnknown = SessionType; + +//@description The session is running on the Vivaldi browser +sessionTypeVivaldi = SessionType; + +//@description The session is running on a Windows device +sessionTypeWindows = SessionType; + +//@description The session is running on an Xbox console +sessionTypeXbox = SessionType; + + //@description Contains information about one session in a Telegram application used by the current user. Sessions must be shown to the user in the returned order //@id Session identifier @is_current True, if this session is the current session //@is_password_pending True, if a password is needed to complete authorization of the session //@can_accept_secret_chats True, if incoming secret chats can be accepted by the session //@can_accept_calls True, if incoming calls can be accepted by the session +//@type Session type based on the system and application version, which can be used to display a corresponding icon //@api_id Telegram API identifier, as provided by the application @application_name Name of the application, as provided by the application //@application_version The version of the application, as provided by the application @is_official_application True, if the application is an official application or uses the api_id of an official application //@device_model Model of the device the application has been run or is running on, as provided by the application @platform Operating system the application has been run or is running on, as provided by the application //@system_version Version of the operating system the application has been run or is running on, as provided by the application @log_in_date Point in time (Unix timestamp) when the user has logged in //@last_active_date Point in time (Unix timestamp) when the session was last used @ip IP address from which the session was created, in human-readable format //@country A two-letter country code for the country from which the session was created, based on the IP address @region Region code from which the session was created, based on the IP address -session id:int64 is_current:Bool is_password_pending:Bool can_accept_secret_chats:Bool can_accept_calls:Bool api_id:int32 application_name:string application_version:string is_official_application:Bool device_model:string platform:string system_version:string log_in_date:int32 last_active_date:int32 ip:string country:string region:string = Session; +session id:int64 is_current:Bool is_password_pending:Bool can_accept_secret_chats:Bool can_accept_calls:Bool type:SessionType api_id:int32 application_name:string application_version:string is_official_application:Bool device_model:string platform:string system_version:string log_in_date:int32 last_active_date:int32 ip:string country:string region:string = Session; //@description Contains a list of sessions @sessions List of sessions @inactive_session_ttl_days Number of days of inactivity before sessions will automatically be terminated; 1-366 days sessions sessions:vector inactive_session_ttl_days:int32 = Sessions; @@ -5428,9 +5483,12 @@ discardCall call_id:int32 is_disconnected:Bool duration:int32 is_video:Bool conn //@description Sends a call rating @call_id Call identifier @rating Call rating; 1-5 @comment An optional user comment if the rating is less than 5 @problems List of the exact types of problems with the call, specified by the user sendCallRating call_id:int32 rating:int32 comment:string problems:vector = Ok; -//@description Sends debug information for a call @call_id Call identifier @debug_information Debug information in application-specific format +//@description Sends debug information for a call to Telegram servers @call_id Call identifier @debug_information Debug information in application-specific format sendCallDebugInformation call_id:int32 debug_information:string = Ok; +//@description Sends log file for a call to Telegram servers @call_id Call identifier @log_file Call log file. Only inputFileLocal and inputFileGenerated are supported +sendCallLog call_id:int32 log_file:InputFile = Ok; + //@description Returns list of participant identifiers, on whose behalf a video chat in the chat can be joined @chat_id Chat identifier getVideoChatAvailableParticipants chat_id:int53 = MessageSenders; @@ -5596,7 +5654,7 @@ changeImportedContacts contacts:vector = ImportedContacts; clearImportedContacts = Ok; -//@description Searches a user by their phone number @phone_number Phone number to search for +//@description Searches a user by their phone number. Returns a 404 error if the user can't be found @phone_number Phone number to search for searchUserByPhoneNumber phone_number:string = User; //@description Shares the phone number of the current user with a mutual contact. Supposed to be called when the user clicks on chatActionBarSharePhoneNumber @user_id Identifier of the user with whom to share the phone number. The user must be a mutual contact