(fix): webhook secret constant-time compare
(fix): observer rename, panic emits ErrorEvent (refactor): Runner.Once removed, Scene.PluginName unexported (doc): godoc hygiene pre-1.0.0
This commit is contained in:
@@ -328,13 +328,11 @@ func (r TelegramRequest[R, P]) Do(api *API) (R, error) {
|
||||
return r.DoWithContext(context.Background(), api)
|
||||
}
|
||||
|
||||
// Internal helper that reads and caps a Telegram response body.
|
||||
func readBody(body io.ReadCloser) ([]byte, error) {
|
||||
reader := io.LimitReader(body, 10<<20) // 10 MB
|
||||
return io.ReadAll(reader)
|
||||
}
|
||||
|
||||
// Internal helper that parses a typed Telegram API response body.
|
||||
func parseBody[R any](data []byte) (TelegramResponse[R], error) {
|
||||
var resp TelegramResponse[R]
|
||||
err := json.Unmarshal(data, &resp)
|
||||
|
||||
@@ -58,6 +58,7 @@ const (
|
||||
// UpdateTypeRemovedChatBoost is a removed chat boost update.
|
||||
UpdateTypeRemovedChatBoost UpdateType = "removed_chat_boost"
|
||||
|
||||
// UpdateTypeManagedBot is a managed bot update.
|
||||
UpdateTypeManagedBot UpdateType = "managed_bot"
|
||||
|
||||
// UpdateTypeGuestMessage is a guest message update.
|
||||
|
||||
@@ -177,10 +177,14 @@ func (r UploaderRequest[R, P]) doRequest(ctx context.Context, up *Uploader) (R,
|
||||
case <-ctx.Done():
|
||||
return zero, ctx.Err()
|
||||
case <-time.After(time.Duration(after) * time.Second):
|
||||
continue // Повторяем запрос
|
||||
continue
|
||||
}
|
||||
}
|
||||
return zero, fmt.Errorf("[%d] %s", response.ErrorCode, response.Description)
|
||||
return zero, &ResponseError{
|
||||
Code: response.ErrorCode,
|
||||
Description: response.Description,
|
||||
Parameters: response.Parameters,
|
||||
}
|
||||
}
|
||||
return response.Result, nil
|
||||
}
|
||||
@@ -218,7 +222,6 @@ func (r UploaderRequest[R, P]) Do(up *Uploader) (R, error) {
|
||||
return r.DoWithContext(context.Background(), up)
|
||||
}
|
||||
|
||||
// Internal helper that builds a finalized multipart body from files and params.
|
||||
func prepareMultipart[P any](files []UploaderFile, params P) (*bytes.Buffer, string, error) {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
w := multipart.NewWriter(buf)
|
||||
@@ -251,7 +254,6 @@ func prepareMultipart[P any](files []UploaderFile, params P) (*bytes.Buffer, str
|
||||
return buf, w.FormDataContentType(), nil
|
||||
}
|
||||
|
||||
// Internal helper that infers an upload field name from a file extension.
|
||||
func uploaderTypeByExt(filename string) UploaderFileType {
|
||||
ext := strings.ToLower(filepath.Ext(filename))
|
||||
switch ext {
|
||||
|
||||
Reference in New Issue
Block a user