BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr
Adjust the response structure of the get_ html API interface
hwliang7ab423c48d9a
diff --git a/core/internal/controller/askai/askai_v1_chat.go b/core/internal/controller/askai/askai_v1_chat.goindex 506e1280..b9cc8053 100644--- a/core/internal/controller/askai/askai_v1_chat.go+++ b/core/internal/controller/askai/askai_v1_chat.go@@ -70,11 +70,15 @@ func (c *ControllerV1) Stop(ctx context.Context, req *v1.StopReq) (res *v1.StopRfunc (c *ControllerV1) GetHtml(ctx context.Context, req *v1.GetHtmlReq) (res *v1.GetHtmlRes, err error) {res = &v1.GetHtmlRes{}- res.Data, err = askai.GetHtml(req.ChatId)+ htmlContent, err := askai.GetHtml(req.ChatId)if err != nil {res.SetError(err)} else {res.SetSuccess("HTML content retrieved successfully")+ res.Data = map[string]interface{}{+ "html_content": htmlContent,+ "last_usage": askai.GetLastUsage(req.ChatId),+ }}return res, nil}diff --git a/core/internal/service/askai/chat.go b/core/internal/service/askai/chat.goindex de06cfba..8fa34ac0 100644--- a/core/internal/service/askai/chat.go+++ b/core/internal/service/askai/chat.go@@ -303,6 +303,17 @@ func Stop(chatId string) error {return nil}+// GetLastUsage retrieves the last usage statistics for a chat by its ID+// This function should handle the logic for loading the last usage statistics of a chat based on the provided chat ID+func GetLastUsage(chatId string) ChatUsage {+ messages := GetMessages(chatId)+ if len(messages) == 0 {+ return ChatUsage{}+ }+ lastMessage := messages[len(messages)-1]+ return lastMessage.Usage+}+// GetHtml retrieves the HTML content of a chat by its ID// This function should handle the logic for loading the HTML content of a chat based on the provided chat IDfunc GetHtml(chatId string) (string, error) {