From fc59317d858c4b2c7c2d5e9a9c2a52ec65ef8654 Mon Sep 17 00:00:00 2001 From: shy Date: Mon, 21 Aug 2023 01:33:55 +0800 Subject: [PATCH] add mail --- base/aaa/email.go | 3 ++- base/ctx/command.go | 4 ++++ base/web/dream.go | 18 ++++++++++++------ base/web/html/html.go | 2 ++ base/web/space.go | 6 ++++++ core/chat/oauth/client.go | 4 ++-- core/code/vimer.go | 6 ++++++ render.go | 2 +- 8 files changed, 35 insertions(+), 10 deletions(-) diff --git a/base/aaa/email.go b/base/aaa/email.go index 8ca6edaa..550abd1c 100644 --- a/base/aaa/email.go +++ b/base/aaa/email.go @@ -27,7 +27,8 @@ func init() { EMAIL: {Name: "email name auto create website", Help: "邮件", Actions: ice.MergeActions(ice.Actions{ "website": {Help: "邮箱", Hand: func(m *ice.Message, arg ...string) { // m.ProcessOpen(m.Cmdv("web.spide", EMAIL, "client.url")) - m.EchoIFrame(m.Cmdv("web.spide", EMAIL, "client.url")).ProcessInner() + // m.EchoIFrame(m.Cmdv("web.spide", EMAIL, "client.url")).ProcessInner() + m.EchoIFrame("/chat/pod/20230511-golang-story/cmd/web.chat.email.client").ProcessInner() }}, SEND: {Name: "send to*='shylinux@163.com' subject*=hi content*:textarea=hello", Help: "发送", Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd("", m.OptionDefault(mdb.NAME, ADMIN)) diff --git a/base/ctx/command.go b/base/ctx/command.go index 47d701e3..ca73f323 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -116,6 +116,10 @@ func PodCmd(m *ice.Message, arg ...ice.Any) bool { m.Options(ice.POD, []string{}, ice.MSG_USERPOD, pod).Cmdy(append(kit.List(ice.SPACE, pod), arg...)...) return true } + if pod := m.Option(ice.SPACE); pod != "" { + m.Options(ice.SPACE, []string{}, ice.MSG_USERPOD, pod).Cmdy(append(kit.List(ice.SPACE, pod), arg...)...) + return true + } return false } func Run(m *ice.Message, arg ...string) { diff --git a/base/web/dream.go b/base/web/dream.go index 086ac07c..dcd9f3dc 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -51,12 +51,18 @@ func _dream_start(m *ice.Message, name string) { } defer m.ProcessOpen(m.MergePod(m.Option(mdb.NAME, name))) p := path.Join(ice.USR_LOCAL_WORK, name) - if pid := m.Cmdx(nfs.CAT, path.Join(p, ice.Info.PidPath), kit.Dict(ice.MSG_USERROLE, aaa.TECH)); pid != "" && nfs.Exists(m, "/proc/"+pid) { - m.Info("already exists %v", pid) - return - } else if msg := m.Cmd(SPACE, name); msg.Length() > 0 { - m.Info("already exists %v", name) - return + if pid := m.Cmdx(nfs.CAT, path.Join(p, ice.Info.PidPath), kit.Dict(ice.MSG_USERROLE, aaa.TECH)); pid != "" { + if nfs.Exists(m, "/proc/"+pid) { + m.Info("already exists %v", pid) + return + } + for i := 0; i < 3; i++ { + if msg := m.Cmd(SPACE, name); msg.Length() > 0 { + m.Info("already exists %v", name) + return + } + m.Sleep("1s") + } } defer ToastProcess(m)() defer m.Sleep("1s") diff --git a/base/web/html/html.go b/base/web/html/html.go index 727fc836..3eeff15b 100644 --- a/base/web/html/html.go +++ b/base/web/html/html.go @@ -10,4 +10,6 @@ const ( const ( FLOAT = "float" OUTPUT = "output" + + TEXT_PLAIN = "text/plain" ) diff --git a/base/web/space.go b/base/web/space.go index 79d8399f..bcbe6949 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -174,6 +174,12 @@ func init() { }) m.Optionv(ice.MSG_ARGS, kit.Simple(m.Optionv(ice.MSG_ARGS))) }}, + mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { + switch arg[0] { + case SPACE: + m.Cmdy("").CutTo(mdb.NAME, arg[0]) + } + }}, tcp.DIAL: {Name: "dial dev=ops name", Hand: func(m *ice.Message, arg ...string) { if strings.HasPrefix(m.Option(ice.DEV), HTTP) { m.Cmd(SPIDE, mdb.CREATE, m.OptionSimple(ice.DEV)) diff --git a/core/chat/oauth/client.go b/core/chat/oauth/client.go index 4166421b..cba40029 100644 --- a/core/chat/oauth/client.go +++ b/core/chat/oauth/client.go @@ -42,7 +42,7 @@ type Client struct { user string `name:"user" help:"用户"` orgs string `name:"orgs" help:"组织"` repo string `name:"repo" help:"源码"` - list string `name:"list hash auto"` + list string `name:"list hash auto" help:"授权"` } func (s Client) Init(m *ice.Message, arg ...string) { @@ -74,7 +74,7 @@ func (s Client) Auth(m *ice.Message, arg ...string) { } func (s Client) User(m *ice.Message, arg ...string) { if res := s.Get(m, m.Option(mdb.HASH), m.Option(USERS_URL)); res != nil { - m.Options(res).Cmd(aaa.USER, mdb.CREATE, aaa.USERNICK, m.Option("full_name"), m.OptionSimple(aaa.USERNAME), + m.Options(res).Cmd(aaa.USER, mdb.CREATE, aaa.USERNICK, m.Option("full_name"), m.OptionSimple(aaa.USERNAME), aaa.AVATAR, m.Option(aaa.AVATAR_URL), aaa.USERROLE, kit.Select(aaa.VOID, aaa.TECH, m.Option("is_admin") == ice.TRUE), aaa.USERZONE, m.Option(web.DOMAIN), m.OptionSimple(aaa.EMAIL, aaa.LANGUAGE, aaa.AVATAR_URL)) } diff --git a/core/code/vimer.go b/core/code/vimer.go index 5a1ac63d..c63a99c8 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -82,6 +82,12 @@ func init() { m.Cmdy(m.Option(ctx.ACTION), mdb.INPUTS, arg) default: switch arg[0] { + case web.SPACE: + m.Cmdy(web.SPACE, mdb.INPUTS, arg) + case ctx.INDEX: + m.Cmdy(web.Space(m, m.Option(web.SPACE)), ctx.COMMAND) + case ctx.ARGS: + m.Cmdy(web.Space(m, m.Option(web.SPACE)), ctx.COMMAND, mdb.INPUTS, m.Option(ctx.INDEX)) case nfs.FILE: list := ice.Map{} push := func(k, p string) { diff --git a/render.go b/render.go index 3adce089..bd62825e 100644 --- a/render.go +++ b/render.go @@ -220,5 +220,5 @@ func (m *Message) resource(file string) string { p = strings.Split(p, "/pkg/mod/")[1] } kit.If(file == "", func() { p = kit.ExtChange(p, "js") }, func() { p = path.Join(path.Dir(p), file) }) - return "/require/" + p + return kit.MergeURL("/require/"+p, POD, m.Option(MSG_USERPOD)) }