From af0d446abc425352d1ae32d7db29631fd9191afa Mon Sep 17 00:00:00 2001 From: shy Date: Mon, 8 Jul 2024 19:45:05 +0800 Subject: [PATCH] opt some --- base/web/serve.go | 5 +++++ base/web/spide.go | 3 +++ core/chat/header.go | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/base/web/serve.go b/base/web/serve.go index 8ab17bb5..02ca814d 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -210,6 +210,11 @@ func _serve_auth(m *ice.Message, key string, cmds []string, w http.ResponseWrite return kit.Simple(m.Time(), m.OptionSplit(ice.MSG_USERNICK, ice.MSG_USERNAME, ice.MSG_USERROLE)) })); len(ls) > 0 { aaa.SessAuth(m, kit.Dict(aaa.USERNICK, ls[1], aaa.USERNAME, ls[2], aaa.USERROLE, ls[3]), CACHE, ls[0]) + } else { + msg := m.Cmd(SPIDE, aaa.USER, "msg", http.MethodPost, "/chat/header/action/info", ice.MSG_SESSID, m.Option(ice.MSG_SESSID)) + if msg.Option(ice.MSG_USERNAME) != "" { + aaa.SessCheck(m, m.Option(ice.MSG_SESSID, aaa.SessCreate(m, msg.Option(ice.MSG_USERNAME)))) + } } } Count(m, aaa.IP, m.Option(ice.MSG_USERIP), m.Option(ice.MSG_USERUA)) diff --git a/base/web/spide.go b/base/web/spide.go index 6f49f757..8880c32b 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -15,6 +15,7 @@ import ( "time" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/log" @@ -201,6 +202,7 @@ func _spide_save(m *ice.Message, action, file, uri string, res *http.Response) { case SPIDE_MSG: var data map[string][]string m.Assert(json.NewDecoder(res.Body).Decode(&data)) + kit.For(data[ice.MSG_OPTION], func(k string) { m.Options(k, data[k]) }) kit.For(data[ice.MSG_APPEND], func(k string) { kit.For(data[k], func(v string) { m.Push(k, v) }) }) m.Resultv(data[ice.MSG_RESULT]) case SPIDE_SAVE: @@ -293,6 +295,7 @@ func init() { m.Cmd("", mdb.CREATE, kit.Select("http://localhost:9020", conf[cli.CTX_OPS]), ice.OPS, nfs.USR_ICONS_CONTEXTS, nfs.REPOS) m.Cmd("", mdb.CREATE, kit.Select("http://localhost:20000", conf[cli.CTX_DEMO]), ice.DEMO, nfs.USR_ICONS_VOLCANOS) m.Cmd("", mdb.CREATE, kit.Select("https://mail.shylinux.com", conf[cli.CTX_MAIL]), ice.MAIL, "usr/icons/Mail.png") + m.Cmd("", mdb.CREATE, kit.Select("https://user.shylinux.com"), aaa.USER, "usr/icons/Mail.png") }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if mdb.IsSearchPreview(m, arg) { diff --git a/core/chat/header.go b/core/chat/header.go index 491d0e8e..3f43b299 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -1,6 +1,7 @@ package chat import ( + "net/http" "path" "strings" "time" @@ -130,6 +131,14 @@ func init() { m.Echo("login failure") } }}, + ice.INFO: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {}}, + aaa.USER: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { + msg := m.Cmd(web.SPIDE, aaa.USER, "msg", http.MethodPost, "/chat/header/action/info", ice.MSG_SESSID, kit.Select(m.Option(ice.MSG_SESSID), arg, 0)) + if msg.Option(ice.MSG_USERNAME) != "" { + aaa.SessCheck(m, m.Option(ice.MSG_SESSID, aaa.SessCreate(m, msg.Option(ice.MSG_USERNAME)))) + m.Echo(m.Option(ice.MSG_SESSID)) + } + }}, }, web.ApiAction(), mdb.ImportantHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,help,icons,order,link,space,index,args")), Hand: func(m *ice.Message, arg ...string) { if ice.Info.NodeType == web.WORKER { return