diff --git a/core/chat/action.go b/core/chat/action.go index b9db7050..20e3e433 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -51,35 +51,39 @@ func _action_exec(m *ice.Message, river, storm, index string, arg ...string) { m.Cmdy(cmds, arg) // 执行命令 } } +func _action_auth(m, msg *ice.Message) bool { + if m.Warn(kit.Time() > kit.Time(msg.Append(mdb.TIME)), ice.ErrNotValid) { + return false + } + m.Log_AUTH( + aaa.USERROLE, m.Option(ice.MSG_USERROLE, msg.Append(aaa.USERROLE)), + aaa.USERNAME, m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)), + aaa.USERNICK, m.Option(ice.MSG_USERNICK, msg.Append(aaa.USERNICK)), + RIVER, m.Option(ice.MSG_RIVER, msg.Append(RIVER)), + STORM, m.Option(ice.MSG_STORM, msg.Append(STORM)), + ) + return _action_right(m, msg.Append(web.RIVER), msg.Append(web.STORM)) +} func _action_share(m *ice.Message, arg ...string) { switch msg := m.Cmd(web.SHARE, arg[0]); msg.Append(mdb.TYPE) { case web.STORM: - if m.Warn(kit.Time() > kit.Time(msg.Append(mdb.TIME)), ice.ErrNotValid, arg) { - break // 分享超时 + if !_action_auth(m, msg) { + break // 没有授权 } + if len(arg) == 1 { _action_list(m, msg.Append(web.RIVER), msg.Append(web.STORM)) break // 命令列表 } - m.Log_AUTH( - aaa.USERROLE, m.Option(ice.MSG_USERROLE, msg.Append(aaa.USERROLE)), - aaa.USERNAME, m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)), - aaa.USERNICK, m.Option(ice.MSG_USERNICK, msg.Append(aaa.USERNICK)), - RIVER, m.Option(ice.MSG_RIVER, msg.Append(RIVER)), - STORM, m.Option(ice.MSG_STORM, msg.Append(STORM)), - ) - if !_action_right(m, msg.Append(web.RIVER), msg.Append(web.STORM)) { - break // 没有授权 - } - // 执行命令 _action_exec(m, msg.Append(web.RIVER), msg.Append(web.STORM), arg[1], arg[2:]...) case web.FIELD: - if m.Warn(kit.Time() > kit.Time(msg.Append(mdb.TIME)), ice.ErrNotValid, arg) { - break // 分享超时 + if !_action_auth(m, msg) { + break // 没有授权 } + if arg[0] = msg.Append(mdb.NAME); len(arg) == 1 { m.Push(TITLE, msg.Append(TITLE)) m.Push(TOPIC, msg.Append(TOPIC)) @@ -88,17 +92,6 @@ func _action_share(m *ice.Message, arg ...string) { break // 命令列表 } - m.Log_AUTH( - aaa.USERROLE, m.Option(ice.MSG_USERROLE, msg.Append(aaa.USERROLE)), - aaa.USERNAME, m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)), - aaa.USERNICK, m.Option(ice.MSG_USERNICK, msg.Append(aaa.USERNICK)), - RIVER, m.Option(ice.MSG_RIVER, msg.Append(RIVER)), - STORM, m.Option(ice.MSG_STORM, msg.Append(STORM)), - ) - if !_action_right(m, msg.Append(web.RIVER), msg.Append(web.STORM)) { - break // 没有授权 - } - if _action_domain(m, arg[1]); m.Option(ice.MSG_UPLOAD) != "" { _action_upload(m) // 上传文件 } @@ -153,10 +146,8 @@ const ( const ACTION = "action" func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ - ACTION: {Name: ACTION, Help: "应用", Value: kit.Data(nfs.PATH, ice.USR_LOCAL_RIVER)}, - }, Commands: map[string]*ice.Command{ - "/action": {Name: "/action river storm action arg...", Help: "工作台", Action: ice.MergeAction(map[string]*ice.Action{ + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + web.P(ACTION): {Name: "/action river storm action arg...", Help: "工作台", Action: ice.MergeAction(map[string]*ice.Action{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { for _, cmd := range []string{ "web.chat.meet.miss", @@ -185,7 +176,7 @@ func init() { "_share": {Name: "_share", Help: "共享", Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + }, ctx.CmdAction(nfs.PATH, ice.USR_LOCAL_RIVER)), Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) { return // 没有登录 } diff --git a/core/chat/footer.go b/core/chat/footer.go index 9d28dfde..e23f7916 100644 --- a/core/chat/footer.go +++ b/core/chat/footer.go @@ -4,6 +4,7 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/ctx" + "shylinux.com/x/icebergs/base/web" kit "shylinux.com/x/toolkits" ) @@ -14,11 +15,9 @@ const FOOTER = "footer" func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ - FOOTER: {Name: FOOTER, Help: "状态栏", Value: kit.Dict( - LEGAL, kit.List(`shylinuxc@gmail.com`), - )}, + FOOTER: {Name: FOOTER, Help: "状态栏", Value: kit.Dict(LEGAL, kit.List(`shylinuxc@gmail.com`))}, }, Commands: map[string]*ice.Command{ - "/footer": {Name: "/footer", Help: "状态栏", Action: ice.MergeAction(map[string]*ice.Action{ + web.P(FOOTER): {Name: "/footer", Help: "状态栏", Action: ice.MergeAction(map[string]*ice.Action{ ice.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) { if m.Cmdy(arg); m.Result(1) == ice.ErrNotFound { m.Set(ice.MSG_RESULT).Cmdy(cli.SYSTEM, arg) diff --git a/core/chat/header.go b/core/chat/header.go index 498f8559..751494b8 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -85,7 +85,7 @@ func init() { } m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) }}, - "/header": {Name: "/header", Help: "标题栏", Action: map[string]*ice.Action{ + web.P(HEADER): {Name: "/header", Help: "标题栏", Action: map[string]*ice.Action{ AGENT: {Name: "agent", Help: "宿主应用", Hand: func(m *ice.Message, arg ...string) { _header_agent(m, arg...) }}, @@ -159,8 +159,6 @@ func init() { GRANT: {Name: "grant space", Help: "授权", Hand: func(m *ice.Message, arg ...string) { _header_grant(m, arg...) }}, - }, Hand: func(m *ice.Message, arg ...string) { - - }}, + }, Hand: func(m *ice.Message, arg ...string) {}}, }}) } diff --git a/core/chat/search.go b/core/chat/search.go index 03df1909..e00f8596 100644 --- a/core/chat/search.go +++ b/core/chat/search.go @@ -1,41 +1,18 @@ package chat import ( - "strings" - ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" - kit "shylinux.com/x/toolkits" + "shylinux.com/x/icebergs/base/web" ) +const SEARCH = "search" + func init() { - Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ - "search": {Name: "search", Help: "搜索", Value: kit.Data(mdb.SHORT, mdb.NAME)}, - }, Commands: map[string]*ice.Command{ - "/search": {Name: "/search", Help: "搜索引擎", Action: ice.MergeAction(map[string]*ice.Action{ - mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { - m.Richs("/search", "", mdb.FOREACH, func(key string, value ice.Map) { - if value = kit.GetMeta(value); arg[1] != "" && !kit.Contains(value[mdb.NAME], arg[1]) { - return - } - m.PushSearch(ice.CMD, "/search", value) - }) - }}, - mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(m.Space(m.Option(ice.POD)), mdb.RENDER, arg[1:]) - }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { - if kit.Contains(arg[1], ";") { - arg = kit.Split(arg[1], ";", ";", ";") - } - defer m.StatusTimeCount() - arg[1] = strings.TrimSpace(arg[1]) - if m.Cmdy(m.Space(m.Option(ice.POD)), mdb.SEARCH, arg); arg[1] == "" { - return - } - m.Cmd(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, - mdb.NAME, arg[1], mdb.TYPE, arg[0], mdb.TEXT, kit.Select("", arg, 2)) + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + web.P(SEARCH): {Name: "/search", Help: "搜索引擎", Action: ctx.CmdAction(mdb.SHORT, mdb.NAME), Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(m.Space(m.Option(ice.POD)), mdb.SEARCH, arg).StatusTimeCount() }}, }}) }