Documentation
¶
Index ¶
- Constants
- func DeriveToken(actor string, kind Kind, payload any) (string, error)
- func PayloadSHA256(payload any) string
- func ValidatePending(a PendingAction, actor string, kind Kind, payload any, confirmation string, ...) error
- type Kind
- type MarkReadExecutor
- type MarkReadPayload
- type MarkReadRequest
- type MarkReadResult
- type MarkReadService
- type MediaDownloadCounts
- type MediaDownloadItem
- type MediaDownloadLimits
- type MediaDownloadManifest
- type MediaDownloadPayload
- type MediaDownloadPeer
- type MediaDownloadPlan
- type MediaDownloadRequest
- type MediaDownloadSafety
- type MediaDownloadService
- type MediaDownloadStatus
- type MediaDownloadWindow
- type MediaFileDownloader
- type PendingAction
- func NewMediaDownloadPending(request MediaDownloadRequest, createdAt time.Time, ttl time.Duration) (PendingAction, error)
- func NewPending(actor string, kind Kind, payload any, createdAt time.Time, ttl time.Duration) (PendingAction, error)
- func NewSendFilePending(request SendFileRequest, createdAt time.Time, ttl time.Duration) (PendingAction, error)
- func NewSendPending(request SendRequest, createdAt time.Time, ttl time.Duration) (PendingAction, error)
- type ReplyExecutor
- type ReplyPayload
- type ReplyRequest
- type ReplyResult
- type ReplyService
- type ScopedPlan
- type ScopedSafety
- type ScopedStatus
- type SendExecutor
- type SendFileExecutor
- type SendFilePayload
- type SendFilePlan
- type SendFilePlanSafety
- type SendFilePlanStatus
- type SendFileRequest
- type SendFileResult
- type SendFileService
- type SendPayload
- type SendPlan
- type SendPlanSafety
- type SendPlanStatus
- type SendRequest
- type SendResult
- type SendService
Constants ¶
View Source
const DefaultConfirmTTL = 10 * time.Minute
View Source
const DefaultSendFileMaxBytes int64 = 25 * 1000 * 1000
Variables ¶
This section is empty.
Functions ¶
func PayloadSHA256 ¶
func ValidatePending ¶
Types ¶
type MarkReadExecutor ¶
type MarkReadExecutor interface {
MarkRead(ctx context.Context, request MarkReadRequest) (MarkReadResult, error)
}
type MarkReadPayload ¶
type MarkReadPayload struct {
AccountID int64 `json:"account_id"`
Peer string `json:"peer"`
PeerID int64 `json:"peer_id"`
PeerKind string `json:"peer_kind"`
MaxID int64 `json:"max_id"`
}
func NewMarkReadPayload ¶
func NewMarkReadPayload(request MarkReadRequest) MarkReadPayload
type MarkReadRequest ¶
type MarkReadResult ¶
type MarkReadService ¶
type MarkReadService struct {
ACL acl.ACL
Executor MarkReadExecutor
Now func() time.Time
TTL time.Duration
}
func (MarkReadService) ConfirmAndMarkRead ¶
func (s MarkReadService) ConfirmAndMarkRead(ctx context.Context, request MarkReadRequest) (MarkReadResult, error)
func (MarkReadService) Plan ¶
func (s MarkReadService) Plan(request MarkReadRequest, dryRun bool) (ScopedPlan, error)
type MediaDownloadCounts ¶
type MediaDownloadItem ¶
type MediaDownloadItem struct {
AccountID int64 `json:"account_id,omitempty"`
PeerID int64 `json:"peer_id,omitempty"`
MessageID int64 `json:"message_id"`
Date string `json:"date"`
FileID int64 `json:"-"`
MediaKind string `json:"media_kind"`
MediaID string `json:"-"`
AccessHash int64 `json:"-"`
FileReference []byte `json:"-"`
ThumbSize string `json:"-"`
DCID int `json:"-"`
MimeType string `json:"mime_type,omitempty"`
SizeBytes int64 `json:"size_bytes"`
FileName string `json:"-"`
Ext string `json:"-"`
PlannedPath string `json:"planned_path,omitempty"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
LocalPath string `json:"local_path,omitempty"`
SHA256 string `json:"sha256,omitempty"`
}
type MediaDownloadLimits ¶
type MediaDownloadManifest ¶
type MediaDownloadManifest struct {
Peer MediaDownloadPeer `json:"peer"`
Window MediaDownloadWindow `json:"window"`
Limits MediaDownloadLimits `json:"limits"`
Counts MediaDownloadCounts `json:"counts"`
Items []MediaDownloadItem `json:"items"`
ManifestPath string `json:"manifest_path"`
CreatedAt string `json:"created_at"`
}
type MediaDownloadPayload ¶
type MediaDownloadPayload struct {
AccountID int64 `json:"account_id"`
Peer string `json:"peer"`
PeerID int64 `json:"peer_id"`
Since string `json:"since"`
Until string `json:"until,omitempty"`
OutDir string `json:"out_dir"`
Limit int `json:"limit"`
MaxFileBytes int64 `json:"max_file_bytes"`
MaxBytes int64 `json:"max_bytes"`
Types []string `json:"types"`
}
func NewMediaDownloadPayload ¶
func NewMediaDownloadPayload(request MediaDownloadRequest) MediaDownloadPayload
func NewMediaDownloadPendingPayload ¶
func NewMediaDownloadPendingPayload(request MediaDownloadRequest) (MediaDownloadPayload, error)
type MediaDownloadPeer ¶
type MediaDownloadPlan ¶
type MediaDownloadPlan struct {
Action Kind `json:"action"`
LiveRead bool `json:"live_read"`
LocalArtifactWrite bool `json:"local_artifact_write"`
Actor string `json:"actor"`
AccountID int64 `json:"account_id"`
Peer string `json:"peer"`
PeerID int64 `json:"peer_id"`
Since string `json:"since"`
Until string `json:"until,omitempty"`
OutDir string `json:"out_dir"`
RequiredPermission acl.Permission `json:"required_permission"`
PermissionGranted bool `json:"permission_granted"`
DryRun bool `json:"dry_run"`
ConfirmationRequired bool `json:"confirmation_required"`
ConfirmationToken string `json:"confirmation_token"`
ConfirmationExpiresAt time.Time `json:"confirmation_expires_at"`
ConfirmationInstruction string `json:"confirmation_instruction"`
Limits MediaDownloadLimits `json:"limits"`
Counts MediaDownloadCounts `json:"counts"`
Items []MediaDownloadItem `json:"items"`
Safety MediaDownloadSafety `json:"safety"`
Status MediaDownloadStatus `json:"status"`
}
type MediaDownloadRequest ¶
type MediaDownloadRequest struct {
Actor string `json:"actor"`
AccountID int64 `json:"account_id"`
Peer string `json:"peer"`
PeerID int64 `json:"peer_id"`
Since string `json:"since"`
Until string `json:"until,omitempty"`
OutDir string `json:"out_dir"`
Limit int `json:"limit"`
MaxFileBytes int64 `json:"max_file_bytes"`
MaxBytes int64 `json:"max_bytes"`
Types []string `json:"types"`
Items []MediaDownloadItem `json:"-"`
}
type MediaDownloadSafety ¶
type MediaDownloadService ¶
type MediaDownloadService struct {
ACL acl.ACL
Downloader MediaFileDownloader
Now func() time.Time
TTL time.Duration
}
func (MediaDownloadService) ConfirmAndDownload ¶
func (s MediaDownloadService) ConfirmAndDownload(ctx context.Context, request MediaDownloadRequest, pending PendingAction, confirmation string) (MediaDownloadManifest, error)
func (MediaDownloadService) Plan ¶
func (s MediaDownloadService) Plan(request MediaDownloadRequest, dryRun bool) (MediaDownloadPlan, error)
type MediaDownloadStatus ¶
type MediaDownloadWindow ¶
type MediaFileDownloader ¶
type PendingAction ¶
type PendingAction struct {
ID int64 `json:"id,omitempty"`
AccountID int64 `json:"account_id,omitempty"`
PeerID int64 `json:"peer_id,omitempty"`
Token string `json:"token"`
Actor string `json:"actor"`
Kind Kind `json:"kind"`
RequiredPermission string `json:"required_permission,omitempty"`
Payload json.RawMessage `json:"payload"`
PayloadSHA256 string `json:"payload_sha256,omitempty"`
Status string `json:"status,omitempty"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
func NewMediaDownloadPending ¶
func NewMediaDownloadPending(request MediaDownloadRequest, createdAt time.Time, ttl time.Duration) (PendingAction, error)
func NewPending ¶
func NewSendFilePending ¶
func NewSendFilePending(request SendFileRequest, createdAt time.Time, ttl time.Duration) (PendingAction, error)
func NewSendPending ¶
func NewSendPending(request SendRequest, createdAt time.Time, ttl time.Duration) (PendingAction, error)
type ReplyExecutor ¶
type ReplyExecutor interface {
Reply(ctx context.Context, request ReplyRequest) (ReplyResult, error)
}
type ReplyPayload ¶
type ReplyPayload struct {
AccountID int64 `json:"account_id"`
Peer string `json:"peer"`
PeerID int64 `json:"peer_id"`
PeerKind string `json:"peer_kind"`
ReplyToMessageID int64 `json:"reply_to_message_id"`
TextSHA256 string `json:"text_sha256"`
TextBytes int `json:"text_bytes"`
TextRunes int `json:"text_runes"`
}
func NewReplyPayload ¶
func NewReplyPayload(request ReplyRequest) ReplyPayload
type ReplyRequest ¶
type ReplyRequest struct {
Actor string `json:"actor"`
AccountID int64 `json:"account_id"`
Peer string `json:"peer"`
PeerID int64 `json:"peer_id"`
PeerKind string `json:"peer_kind"`
AccessHash *int64 `json:"-"`
ReplyToMessageID int64 `json:"reply_to_message_id"`
Text string `json:"text,omitempty"`
}
type ReplyResult ¶
type ReplyService ¶
type ReplyService struct {
ACL acl.ACL
Executor ReplyExecutor
Now func() time.Time
TTL time.Duration
}
func (ReplyService) ConfirmAndReply ¶
func (s ReplyService) ConfirmAndReply(ctx context.Context, request ReplyRequest) (ReplyResult, error)
func (ReplyService) Plan ¶
func (s ReplyService) Plan(request ReplyRequest, dryRun bool) (ScopedPlan, error)
type ScopedPlan ¶
type ScopedPlan struct {
Action Kind `json:"action"`
WriteCapable bool `json:"write_capable"`
Actor string `json:"actor"`
AccountID int64 `json:"account_id"`
Peer string `json:"peer"`
PeerID int64 `json:"peer_id"`
PeerKind string `json:"peer_kind"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
MaxID int64 `json:"max_id,omitempty"`
RequiredPermission acl.Permission `json:"required_permission"`
PermissionGranted bool `json:"permission_granted"`
DryRun bool `json:"dry_run"`
ConfirmationRequired bool `json:"confirmation_required"`
ConfirmationToken string `json:"confirmation_token"`
ConfirmationExpiresAt time.Time `json:"confirmation_expires_at"`
ConfirmationInstruction string `json:"confirmation_instruction"`
Payload any `json:"payload"`
Safety ScopedSafety `json:"safety"`
Status ScopedStatus `json:"status"`
}
type ScopedSafety ¶
type ScopedSafety struct {
NoNetwork bool `json:"no_network"`
LocalScopeOnly bool `json:"local_scope_only"`
MessageTextRedacted bool `json:"message_text_redacted,omitempty"`
AccessHashesRedacted bool `json:"access_hashes_redacted"`
TelegramTextUntrusted bool `json:"telegram_text_untrusted"`
Notes string `json:"notes"`
}
type ScopedStatus ¶
type SendExecutor ¶
type SendExecutor interface {
Send(ctx context.Context, request SendRequest) (SendResult, error)
}
type SendFileExecutor ¶
type SendFileExecutor interface {
SendFile(ctx context.Context, request SendFileRequest) (SendFileResult, error)
}
type SendFilePayload ¶
type SendFilePayload struct {
Peer string `json:"peer"`
FilePath string `json:"file_path"`
FileBytes int64 `json:"file_bytes"`
FileSHA256 string `json:"file_sha256"`
MIMEType string `json:"mime_type"`
Filename string `json:"filename"`
MaxFileBytes int64 `json:"max_file_bytes"`
CaptionSHA256 string `json:"caption_sha256,omitempty"`
CaptionBytes int `json:"caption_bytes,omitempty"`
CaptionRunes int `json:"caption_runes,omitempty"`
}
func NewSendFilePendingPayload ¶
func NewSendFilePendingPayload(request SendFileRequest) (SendFilePayload, error)
type SendFilePlan ¶
type SendFilePlan struct {
Action Kind `json:"action"`
WriteCapable bool `json:"write_capable"`
Actor string `json:"actor"`
Peer string `json:"peer"`
RequiredPermission acl.Permission `json:"required_permission"`
PermissionGranted bool `json:"permission_granted"`
DryRun bool `json:"dry_run"`
ConfirmationRequired bool `json:"confirmation_required"`
ConfirmationToken string `json:"confirmation_token"`
ConfirmationExpiresAt time.Time `json:"confirmation_expires_at"`
ConfirmationInstruction string `json:"confirmation_instruction"`
Payload SendFilePayload `json:"payload"`
Safety SendFilePlanSafety `json:"safety"`
Status SendFilePlanStatus `json:"status"`
}
type SendFilePlanSafety ¶
type SendFilePlanStatus ¶
type SendFileRequest ¶
type SendFileRequest struct {
Actor string `json:"actor"`
Peer string `json:"peer"`
FilePath string `json:"file_path"`
UploadPath string `json:"-"`
Caption string `json:"caption,omitempty"`
MIMEType string `json:"mime_type,omitempty"`
Filename string `json:"filename,omitempty"`
MaxFileBytes int64 `json:"max_file_bytes"`
}
type SendFileResult ¶
type SendFileService ¶
type SendFileService struct {
ACL acl.ACL
Executor SendFileExecutor
Now func() time.Time
TTL time.Duration
}
func (SendFileService) ConfirmAndSendFile ¶
func (s SendFileService) ConfirmAndSendFile(ctx context.Context, request SendFileRequest, pending PendingAction, confirmation string) (SendFileResult, error)
func (SendFileService) Plan ¶
func (s SendFileService) Plan(request SendFileRequest, dryRun bool) (SendFilePlan, error)
type SendPayload ¶
type SendPayload struct {
Peer string `json:"peer"`
TextSHA256 string `json:"text_sha256"`
TextBytes int `json:"text_bytes"`
TextRunes int `json:"text_runes"`
}
func NewSendPayload ¶
func NewSendPayload(request SendRequest) SendPayload
func NewSendPendingPayload ¶
func NewSendPendingPayload(request SendRequest) (SendPayload, error)
type SendPlan ¶
type SendPlan struct {
Action Kind `json:"action"`
WriteCapable bool `json:"write_capable"`
Actor string `json:"actor"`
Peer string `json:"peer"`
RequiredPermission acl.Permission `json:"required_permission"`
PermissionGranted bool `json:"permission_granted"`
DryRun bool `json:"dry_run"`
ConfirmationRequired bool `json:"confirmation_required"`
ConfirmationToken string `json:"confirmation_token"`
ConfirmationExpiresAt time.Time `json:"confirmation_expires_at"`
ConfirmationInstruction string `json:"confirmation_instruction"`
Payload SendPayload `json:"payload"`
Safety SendPlanSafety `json:"safety"`
Status SendPlanStatus `json:"status"`
}
type SendPlanSafety ¶
type SendPlanStatus ¶
type SendRequest ¶
type SendResult ¶
type SendService ¶
type SendService struct {
ACL acl.ACL
Executor SendExecutor
Now func() time.Time
TTL time.Duration
}
func (SendService) ConfirmAndSend ¶
func (s SendService) ConfirmAndSend(ctx context.Context, request SendRequest, pending PendingAction, confirmation string) (SendResult, error)
func (SendService) Plan ¶
func (s SendService) Plan(request SendRequest, dryRun bool) (SendPlan, error)
Click to show internal directories.
Click to hide internal directories.