summaryrefslogtreecommitdiff
path: root/shrine
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-03-07 12:15:16 +0530
committerBobby <[email protected]>2026-03-07 12:15:16 +0530
commit67faa7aa2a6e59555dd92ead1c72631267e14be9 (patch)
treecfa57e2a404b12fa4957f76c57c97bb317812e93 /shrine
parent9d37256e004cb381edc7b0b7c0c05ecf1674ee4d (diff)
downloadpagoda-67faa7aa2a6e59555dd92ead1c72631267e14be9.tar.xz
pagoda-67faa7aa2a6e59555dd92ead1c72631267e14be9.zip
feat: add modal component and styles, implement config API
- Created a new Modal component in Solid.js with backdrop handling. - Added modal styles for backdrop, content, header, and body. - Introduced editor styles for a rich text editor interface. - Implemented a new config controller and service in Go to fetch configuration settings. - Defined a ConfigResponse type for structured API responses. - Set up routing for the config endpoint in the Go application.
Diffstat (limited to 'shrine')
-rw-r--r--shrine/controllers/config.go12
-rw-r--r--shrine/router/config.go13
-rw-r--r--shrine/services/config.go13
-rw-r--r--shrine/services/letter.go6
-rw-r--r--shrine/types/config/response.go6
-rw-r--r--shrine/types/letter/request.go10
-rw-r--r--shrine/utils/storage/storage.go7
7 files changed, 60 insertions, 7 deletions
diff --git a/shrine/controllers/config.go b/shrine/controllers/config.go
new file mode 100644
index 0000000..6a32f3d
--- /dev/null
+++ b/shrine/controllers/config.go
@@ -0,0 +1,12 @@
+package controllers
+
+import (
+ "shrine/services"
+ "shrine/utils/shortcuts"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+func ConfigController(context *fiber.Ctx) error {
+ return shortcuts.Success(context, services.GetConfig())
+} \ No newline at end of file
diff --git a/shrine/router/config.go b/shrine/router/config.go
new file mode 100644
index 0000000..72a3063
--- /dev/null
+++ b/shrine/router/config.go
@@ -0,0 +1,13 @@
+package router
+
+import (
+ "shrine/controllers"
+ "shrine/enums"
+ "shrine/utils/urls"
+)
+
+func init() {
+ urls.SetNamespace("config")
+
+ urls.Path(enums.GET, "/", controllers.ConfigController, "index")
+} \ No newline at end of file
diff --git a/shrine/services/config.go b/shrine/services/config.go
new file mode 100644
index 0000000..6077d1e
--- /dev/null
+++ b/shrine/services/config.go
@@ -0,0 +1,13 @@
+package services
+
+import (
+ "shrine/config"
+ configTypes "shrine/types/config"
+)
+
+func GetConfig() configTypes.ConfigResponse {
+ return configTypes.ConfigResponse{
+ MaxFileSize: config.Storage.MaxFileSize,
+ MaxAttachments: config.Storage.MaxAttachments,
+ }
+} \ No newline at end of file
diff --git a/shrine/services/letter.go b/shrine/services/letter.go
index 66bf9b8..e9bd825 100644
--- a/shrine/services/letter.go
+++ b/shrine/services/letter.go
@@ -84,7 +84,7 @@ func CreateLetter(userID uint, request letter.CreateRequest) (*common.MessageRes
if len(recipientIDs) == 1 && request.Title == "" {
existing := repositories.FindExistingDM(userID, recipientIDs[0])
if existing != nil {
- _, err := repositories.SendMessage(existing.ID, userID, sanitizedBody, nil)
+ _, err := repositories.SendMessage(existing.ID, userID, sanitizedBody, request.AttachmentRefs)
if err != nil {
return nil, fail(enums.Internal, messages.FailedSendMessage)
}
@@ -92,7 +92,7 @@ func CreateLetter(userID uint, request letter.CreateRequest) (*common.MessageRes
}
}
- record, err := repositories.CreateLetter(userID, strings.TrimSpace(request.Title), recipientIDs, sanitizedBody, nil)
+ record, err := repositories.CreateLetter(userID, strings.TrimSpace(request.Title), recipientIDs, sanitizedBody, request.AttachmentRefs)
if err != nil {
return nil, fail(enums.Internal, messages.FailedCreateLetter)
}
@@ -115,7 +115,7 @@ func SendLetterMessage(ref string, userID uint, request letter.SendMessageReques
return nil, serviceErr
}
- message, err := repositories.SendMessage(record.ID, userID, sanitizedBody, nil)
+ message, err := repositories.SendMessage(record.ID, userID, sanitizedBody, request.AttachmentRefs)
if err != nil {
return nil, fail(enums.Internal, messages.FailedSendMessage)
}
diff --git a/shrine/types/config/response.go b/shrine/types/config/response.go
new file mode 100644
index 0000000..9d37d5d
--- /dev/null
+++ b/shrine/types/config/response.go
@@ -0,0 +1,6 @@
+package config
+
+type ConfigResponse struct {
+ MaxFileSize int64 `json:"max_file_size"`
+ MaxAttachments int `json:"max_attachments"`
+} \ No newline at end of file
diff --git a/shrine/types/letter/request.go b/shrine/types/letter/request.go
index 2687352..69236d4 100644
--- a/shrine/types/letter/request.go
+++ b/shrine/types/letter/request.go
@@ -1,13 +1,15 @@
package letter
type CreateRequest struct {
- Recipients []string `json:"recipients"`
- Title string `json:"title"`
- Body string `json:"body"`
+ Recipients []string `json:"recipients"`
+ Title string `json:"title"`
+ Body string `json:"body"`
+ AttachmentRefs []string `json:"attachment_refs"`
}
type SendMessageRequest struct {
- Body string `json:"body"`
+ Body string `json:"body"`
+ AttachmentRefs []string `json:"attachment_refs"`
}
type EditMessageRequest struct {
diff --git a/shrine/utils/storage/storage.go b/shrine/utils/storage/storage.go
index 32b3db5..3dcaebe 100644
--- a/shrine/utils/storage/storage.go
+++ b/shrine/utils/storage/storage.go
@@ -2,6 +2,7 @@ package storage
import (
"context"
+ "fmt"
"io"
"shrine/config"
"shrine/utils/logger"
@@ -32,6 +33,9 @@ func init() {
}
func Upload(path string, reader io.Reader, size int64, contentType string) error {
+ if Client == nil {
+ return fmt.Errorf("storage not configured")
+ }
_, err := Client.PutObject(context.Background(), config.Storage.Bucket, path, reader, size, minio.PutObjectOptions{
ContentType: contentType,
})
@@ -39,6 +43,9 @@ func Upload(path string, reader io.Reader, size int64, contentType string) error
}
func Delete(path string) error {
+ if Client == nil {
+ return fmt.Errorf("storage not configured")
+ }
return Client.RemoveObject(context.Background(), config.Storage.Bucket, path, minio.RemoveObjectOptions{})
}