From 2cd5babcfaa3c6704b5fcb928a035f5b4edb96ac Mon Sep 17 00:00:00 2001 From: merlinfuchs Date: Thu, 19 Sep 2024 17:23:44 +0200 Subject: [PATCH] add health endpoint --- embedg-server/api/handlers/send_message/restore.go | 2 ++ embedg-server/api/routes.go | 4 ++++ embedg-server/db/s3/files.go | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/embedg-server/api/handlers/send_message/restore.go b/embedg-server/api/handlers/send_message/restore.go index 74ce384e5..a7b78a161 100644 --- a/embedg-server/api/handlers/send_message/restore.go +++ b/embedg-server/api/handlers/send_message/restore.go @@ -101,6 +101,8 @@ func (h *SendMessageHandler) HandleRestoreMessageFromWebhook(c *fiber.Ctx, req w func downloadMessageAttachments(attachments []*discordgo.MessageAttachment) (files []*wire.MessageAttachmentWire) { filesC := make(chan *wire.MessageAttachmentWire) + // TODO: can this block forever? + for _, attachment := range attachments { go func(attachment *discordgo.MessageAttachment) { if attachment.Size > 8*1024*1024 { diff --git a/embedg-server/api/routes.go b/embedg-server/api/routes.go index bb855cc11..cdd5b6587 100644 --- a/embedg-server/api/routes.go +++ b/embedg-server/api/routes.go @@ -28,6 +28,10 @@ import ( ) func registerRoutes(app *fiber.App, stores *stores, bot *bot.Bot, managers *managers) { + app.Get("/api/health", func(c *fiber.Ctx) error { + return c.SendStatus(fiber.StatusOK) + }) + authHandler := auth.New(stores.pg, bot, managers.session) app.Get("/api/auth/login", authHandler.HandleAuthRedirect) app.Get("/api/auth/callback", authHandler.HandleAuthCallback) diff --git a/embedg-server/db/s3/files.go b/embedg-server/db/s3/files.go index 650fb6897..1852737b3 100644 --- a/embedg-server/db/s3/files.go +++ b/embedg-server/db/s3/files.go @@ -12,7 +12,9 @@ const imagesBucketName = "images" func (s *BlobStore) UploadFile(ctx context.Context, image *Image) error { reader := bytes.NewReader(image.Body) - _, err := s.client.PutObject(ctx, imagesBucketName, image.FileName, reader, int64(len(image.Body)), minio.PutObjectOptions{}) + _, err := s.client.PutObject(ctx, imagesBucketName, image.FileName, reader, int64(len(image.Body)), minio.PutObjectOptions{ + ContentType: image.ContentType, + }) if err != nil { return err }