init: Initial commit

This commit is contained in:
Björn Benouarets
2026-01-20 06:53:05 +01:00
commit fc8238759a
31 changed files with 1384 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package services
import (
"git.secnex.io/secnex/masterlog"
"git.secnex.io/secnex/taro-bot/bot"
"git.secnex.io/secnex/taro-bot/repositories"
"git.secnex.io/secnex/taro-bot/utils"
"github.com/gofiber/fiber/v2"
"github.com/google/uuid"
)
func ExecuteWebhook(channelId uuid.UUID, body utils.HTTPBody) *utils.HTTPResponse {
channel, err := repositories.GetChannelByID(channelId.String())
if err != nil {
return utils.NewHTTPResponse(fiber.StatusInternalServerError, &fiber.Map{
"message": "Failed to get channel",
}, "", nil, nil)
}
text := "New webhook received!"
conversation := bot.NewConversation(*bot.AUTH)
err = conversation.SendMessage(bot.NewTextPost(channel.ExternalID, text))
if err != nil {
return utils.NewHTTPResponse(fiber.StatusInternalServerError, &fiber.Map{
"message": "Failed to send message",
}, "", nil, nil)
}
masterlog.Info("Webhook executed successfully", map[string]interface{}{"channelId": channelId, "text": text})
return utils.NewHTTPResponse(fiber.StatusOK, &fiber.Map{
"message": "Webhook executed successfully",
}, "", nil, nil)
}