You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
615 B
30 lines
615 B
package webhookeverything
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
"net/http/httputil"
|
|
)
|
|
|
|
func (env *Env) forwardHookToTelegram(r *http.Request, routeID string) error {
|
|
// Get Telegram code
|
|
var routeResult WebhookRoute
|
|
err := env.DB.Where(&WebhookRoute{WebhookID: routeID}).First(&routeResult).Error
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Dump request as string
|
|
responseBytes, err := httputil.DumpRequest(r, true)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Print on screenn
|
|
log.Println(string(responseBytes))
|
|
|
|
// Send telegram
|
|
env.TelegramEnv.TelegramSend(routeResult.TelegramShortCode, string(responseBytes))
|
|
|
|
return nil
|
|
}
|