1、修复邮件插入失败 2、插件支持设置页面 3、修复pop3邮箱拉取权限判断 4、修复非管理员账户的附件权限判断 Co-authored-by: jinnrry <i@jinnrry.com>
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package controllers
|
|
|
|
import (
|
|
"github.com/Jinnrry/pmail/dto/response"
|
|
"github.com/Jinnrry/pmail/hooks"
|
|
"github.com/Jinnrry/pmail/utils/context"
|
|
"io"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
func GetPluginList(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
|
ret := []string{}
|
|
for s, _ := range hooks.HookList {
|
|
ret = append(ret, s)
|
|
}
|
|
response.NewSuccessResponse(ret).FPrint(w)
|
|
|
|
}
|
|
|
|
func SettingsHtml(ctx *context.Context, w http.ResponseWriter, req *http.Request) {
|
|
args := strings.Split(req.RequestURI, "/")
|
|
if len(args) < 4 {
|
|
response.NewErrorResponse(response.ParamsError, "404", "").FPrint(w)
|
|
return
|
|
}
|
|
|
|
pluginName := args[4]
|
|
if plugin, ok := hooks.HookList[pluginName]; ok {
|
|
dt, err := io.ReadAll(req.Body)
|
|
if err != nil {
|
|
response.NewErrorResponse(response.ParamsError, err.Error(), "").FPrint(w)
|
|
return
|
|
}
|
|
html := plugin.SettingsHtml(ctx,
|
|
strings.Join(args[4:], "/"),
|
|
string(dt),
|
|
)
|
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
|
|
w.Write([]byte(html))
|
|
return
|
|
|
|
}
|
|
response.NewErrorResponse(response.ParamsError, "404", "")
|
|
}
|