move gotd fork into repo. (#111)
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
// Code generated by gotdgen, DO NOT EDIT.
|
||||
|
||||
package tg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"go.uber.org/multierr"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
|
||||
)
|
||||
|
||||
// No-op definition for keeping imports.
|
||||
var (
|
||||
_ = bin.Buffer{}
|
||||
_ = context.Background()
|
||||
_ = fmt.Stringer(nil)
|
||||
_ = strings.Builder{}
|
||||
_ = errors.Is
|
||||
_ = multierr.AppendInto
|
||||
_ = sort.Ints
|
||||
_ = tdp.Format
|
||||
_ = tgerr.Error{}
|
||||
_ = tdjson.Encoder{}
|
||||
)
|
||||
|
||||
// AuthResetAuthorizationsRequest represents TL type `auth.resetAuthorizations#9fab0d1a`.
|
||||
// Terminates all user's authorized sessions except for the current one.
|
||||
// After calling this method it is necessary to reregister the current device using the
|
||||
// method account.registerDevice¹
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/method/account.registerDevice
|
||||
//
|
||||
// See https://core.telegram.org/method/auth.resetAuthorizations for reference.
|
||||
type AuthResetAuthorizationsRequest struct {
|
||||
}
|
||||
|
||||
// AuthResetAuthorizationsRequestTypeID is TL type id of AuthResetAuthorizationsRequest.
|
||||
const AuthResetAuthorizationsRequestTypeID = 0x9fab0d1a
|
||||
|
||||
// Ensuring interfaces in compile-time for AuthResetAuthorizationsRequest.
|
||||
var (
|
||||
_ bin.Encoder = &AuthResetAuthorizationsRequest{}
|
||||
_ bin.Decoder = &AuthResetAuthorizationsRequest{}
|
||||
_ bin.BareEncoder = &AuthResetAuthorizationsRequest{}
|
||||
_ bin.BareDecoder = &AuthResetAuthorizationsRequest{}
|
||||
)
|
||||
|
||||
func (r *AuthResetAuthorizationsRequest) Zero() bool {
|
||||
if r == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (r *AuthResetAuthorizationsRequest) String() string {
|
||||
if r == nil {
|
||||
return "AuthResetAuthorizationsRequest(nil)"
|
||||
}
|
||||
type Alias AuthResetAuthorizationsRequest
|
||||
return fmt.Sprintf("AuthResetAuthorizationsRequest%+v", Alias(*r))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*AuthResetAuthorizationsRequest) TypeID() uint32 {
|
||||
return AuthResetAuthorizationsRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*AuthResetAuthorizationsRequest) TypeName() string {
|
||||
return "auth.resetAuthorizations"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (r *AuthResetAuthorizationsRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "auth.resetAuthorizations",
|
||||
ID: AuthResetAuthorizationsRequestTypeID,
|
||||
}
|
||||
if r == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (r *AuthResetAuthorizationsRequest) Encode(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't encode auth.resetAuthorizations#9fab0d1a as nil")
|
||||
}
|
||||
b.PutID(AuthResetAuthorizationsRequestTypeID)
|
||||
return r.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (r *AuthResetAuthorizationsRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't encode auth.resetAuthorizations#9fab0d1a as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (r *AuthResetAuthorizationsRequest) Decode(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't decode auth.resetAuthorizations#9fab0d1a to nil")
|
||||
}
|
||||
if err := b.ConsumeID(AuthResetAuthorizationsRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode auth.resetAuthorizations#9fab0d1a: %w", err)
|
||||
}
|
||||
return r.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (r *AuthResetAuthorizationsRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't decode auth.resetAuthorizations#9fab0d1a to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AuthResetAuthorizations invokes method auth.resetAuthorizations#9fab0d1a returning error if any.
|
||||
// Terminates all user's authorized sessions except for the current one.
|
||||
// After calling this method it is necessary to reregister the current device using the
|
||||
// method account.registerDevice¹
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/method/account.registerDevice
|
||||
//
|
||||
// Possible errors:
|
||||
//
|
||||
// 406 FRESH_RESET_AUTHORISATION_FORBIDDEN: You can't logout other sessions if less than 24 hours have passed since you logged on the current session.
|
||||
//
|
||||
// See https://core.telegram.org/method/auth.resetAuthorizations for reference.
|
||||
func (c *Client) AuthResetAuthorizations(ctx context.Context) (bool, error) {
|
||||
var result BoolBox
|
||||
|
||||
request := &AuthResetAuthorizationsRequest{}
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return false, err
|
||||
}
|
||||
_, ok := result.Bool.(*BoolTrue)
|
||||
return ok, nil
|
||||
}
|
||||
Reference in New Issue
Block a user