mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
add some
This commit is contained in:
parent
89f39ae9a4
commit
2c791bef93
@ -4,17 +4,37 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web/html"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _offer_create(m *ice.Message, arg ...string) {
|
||||
h := mdb.HashCreate(m.Spawn(), m.OptionSimple(EMAIL, SUBJECT, CONTENT), INVITER, m.Option(ice.MSG_USERNAME), mdb.STATUS, INVITE)
|
||||
SendEmail(m.Options("link", m.Cmdx("host", "publish", m.MergePodCmd("", "", mdb.HASH, h))), m.Option(FROM), "", "")
|
||||
m.Cmd("count", mdb.CREATE, OFFER, m.Option(FROM), kit.Dict(ice.LOG_DISABLE, ice.TRUE))
|
||||
gdb.Event(m, OFFER_CREATE, mdb.HASH, h, EMAIL, m.Option(EMAIL))
|
||||
}
|
||||
func _offer_accept(m *ice.Message, arg ...string) {
|
||||
msg := mdb.HashSelect(m.Spawn(), m.Option(mdb.HASH))
|
||||
if ls := kit.Split(msg.Append(EMAIL), mdb.AT); !m.WarnNotFound(msg.Length() == 0 || len(ls) < 2, m.Option(mdb.HASH)) {
|
||||
m.Spawn().AdminCmd(USER, mdb.CREATE, USERNICK, ls[0], USERNAME, msg.Append(EMAIL), USERZONE, ls[1])
|
||||
m.ProcessLocation(m.MergePod("", ice.MSG_SESSID, SessValid(m.Options(ice.MSG_USERNAME, msg.Append(EMAIL)))))
|
||||
mdb.HashModify(m, m.OptionSimple(mdb.HASH), mdb.STATUS, ACCEPT)
|
||||
gdb.Event(m, OFFER_ACCEPT, mdb.HASH, m.Option(mdb.HASH), EMAIL, msg.Append(EMAIL))
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
INVITER = "inviter"
|
||||
INVITE = "invite"
|
||||
ACCEPT = "accept"
|
||||
SUBJECT_HTML = "subject.html"
|
||||
CONTENT_HTML = "content.html"
|
||||
|
||||
OFFER_CREATE = "offer.create"
|
||||
OFFER_ACCEPT = "offer.accept"
|
||||
)
|
||||
const APPLY = "apply"
|
||||
const OFFER = "offer"
|
||||
@ -25,19 +45,11 @@ func init() {
|
||||
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict("from", "发自", "inviter", "邀请人")),
|
||||
), Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.CREATE: {Name: "create from*=admin email*='shy@shylinux.com' subject content", Help: "邀请", Hand: func(m *ice.Message, arg ...string) {
|
||||
h := mdb.HashCreate(m.Spawn(), m.OptionSimple(EMAIL, SUBJECT, CONTENT), INVITER, m.Option(ice.MSG_USERNAME), mdb.STATUS, INVITE)
|
||||
SendEmail(m.Options("link", m.Cmdx("host", "publish", m.MergePodCmd("", "", mdb.HASH, h))), m.Option(FROM), "", "")
|
||||
m.Cmd("count", mdb.CREATE, OFFER, m.Option(FROM), kit.Dict(ice.LOG_DISABLE, ice.TRUE))
|
||||
_offer_create(m, arg...)
|
||||
}},
|
||||
ACCEPT: {Help: "接受", Role: VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.WarnNotValid(m.Option(mdb.HASH), mdb.HASH) {
|
||||
return
|
||||
}
|
||||
msg := mdb.HashSelect(m.Spawn(), m.Option(mdb.HASH))
|
||||
if ls := kit.Split(msg.Append(EMAIL), mdb.AT); !m.WarnNotFound(msg.Length() == 0 || len(ls) < 2, m.Option(mdb.HASH)) {
|
||||
m.Spawn().AdminCmd(USER, mdb.CREATE, USERNICK, ls[0], USERNAME, msg.Append(EMAIL), USERZONE, ls[1])
|
||||
m.ProcessLocation(m.MergePod("", ice.MSG_SESSID, SessValid(m.Options(ice.MSG_USERNAME, msg.Append(EMAIL)))))
|
||||
mdb.HashModify(m, m.OptionSimple(mdb.HASH), mdb.STATUS, ACCEPT)
|
||||
if !m.WarnNotValid(m.Option(mdb.HASH), mdb.HASH) {
|
||||
_offer_accept(m, arg...)
|
||||
}
|
||||
}},
|
||||
}, mdb.ImportantHashAction(EMAIL, ADMIN, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,status,inviter,email,title,content")), Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -47,7 +59,10 @@ func init() {
|
||||
m.Option(ice.MSG_USERHOST, strings.Split(m.Option(ice.MSG_USERHOST), "://")[1])
|
||||
m.SetAppend().EchoInfoButton(m.Template(SUBJECT_HTML), ACCEPT)
|
||||
} else {
|
||||
m.ProcessLocation(m.MergePod(""))
|
||||
if strings.Contains(m.Option(ice.MSG_USERWEB), "/c/offer") {
|
||||
m.ProcessLocation(m.MergePod(""))
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -40,8 +40,7 @@ func init() {
|
||||
mdb.HashSelectUpdate(m, arg[0], func(value ice.Map) { kit.Value(value, mdb.TIME, m.Time()) })
|
||||
web.StreamPushRefreshConfirm(m, m.Trans("refresh for new message ", "刷新列表,查看最新消息 "))
|
||||
}},
|
||||
cli.CLEAR: {Hand: func(m *ice.Message, arg ...string) {
|
||||
}},
|
||||
cli.CLEAR: {Hand: func(m *ice.Message, arg ...string) {}},
|
||||
tcp.SEND: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd("", mdb.INSERT, arg, tcp.DIRECT, tcp.SEND)
|
||||
kit.If(mdb.HashSelectField(m, arg[0], web.TARGET), func(p string) { m.Cmd(web.SPACE, p, MESSAGE, tcp.RECV, arg[1:]) })
|
||||
@ -52,20 +51,22 @@ func init() {
|
||||
}},
|
||||
web.OPEN: {Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.MergePod(m.Option(web.TARGET))) }},
|
||||
web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if ice.Info.Important {
|
||||
MessageInsert(m, web.DREAM, mdb.TYPE, html.PLUG, ctx.INDEX, IFRAME, ctx.ARGS, web.S(m.Option(mdb.NAME)))
|
||||
}
|
||||
MessageInsertPlug(m, web.DREAM, "", "", IFRAME, web.S(m.Option(mdb.NAME)))
|
||||
}},
|
||||
web.SPACE_LOGIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
MessageInsert(m, aaa.APPLY, mdb.TYPE, html.PLUG, mdb.NAME, m.ActionKey(), ctx.INDEX, web.CHAT_GRANT, ctx.ARGS, m.Option(mdb.NAME))
|
||||
MessageInsertPlug(m, aaa.APPLY, "", "", web.CHAT_GRANT, m.Option(mdb.NAME))
|
||||
}},
|
||||
aaa.OFFER_CREATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
MessageInsertPlug(m, aaa.APPLY, "", "", aaa.OFFER, m.Option(mdb.HASH))
|
||||
}},
|
||||
aaa.OFFER_ACCEPT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
MessageInsertPlug(m, aaa.APPLY, "", "", aaa.OFFER, m.Option(mdb.HASH))
|
||||
}},
|
||||
aaa.USER_CREATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if ice.Info.Important {
|
||||
MessageInsert(m, aaa.APPLY, mdb.TYPE, html.PLUG, mdb.NAME, m.ActionKey(), ctx.INDEX, aaa.USER, ctx.ARGS, m.Option(aaa.USERNAME))
|
||||
}
|
||||
MessageInsertPlug(m, aaa.APPLY, "", "", aaa.USER, m.Option(aaa.USERNAME))
|
||||
}},
|
||||
aaa.USER_REMOVE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
MessageInsert(m, aaa.APPLY, mdb.TYPE, html.PLUG, mdb.NAME, m.ActionKey(), ctx.INDEX, aaa.USER, ctx.ARGS, m.Option(aaa.USERNAME))
|
||||
MessageInsertPlug(m, aaa.APPLY, "", "", aaa.USER, m.Option(aaa.USERNAME))
|
||||
}},
|
||||
ctx.COMMAND: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(tcp.DIRECT) == tcp.RECV {
|
||||
@ -75,7 +76,10 @@ func init() {
|
||||
}
|
||||
}},
|
||||
ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(web.Space(m, arg[0]), arg[1], arg[2:]) }},
|
||||
}, web.DreamAction(), web.DreamTablesAction(), gdb.EventsAction(aaa.USER_CREATE, aaa.USER_REMOVE), mdb.ZoneAction(
|
||||
}, web.DreamAction(), web.DreamTablesAction(), gdb.EventsAction(
|
||||
aaa.OFFER_CREATE, aaa.OFFER_ACCEPT,
|
||||
aaa.USER_CREATE, aaa.USER_REMOVE,
|
||||
), mdb.ZoneAction(
|
||||
mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,hash,type,zone,icons,title,count,target",
|
||||
mdb.FIELDS, "time,id,type,name,text,space,index,args,style,display,username,usernick,avatar,direct",
|
||||
web.ONLINE, ice.TRUE,
|
||||
@ -114,3 +118,6 @@ func MessageCreate(m *ice.Message, zone, icons string) {
|
||||
func MessageInsert(m *ice.Message, zone string, arg ...string) {
|
||||
m.Cmd(MESSAGE, mdb.INSERT, zone, tcp.DIRECT, tcp.RECV, arg)
|
||||
}
|
||||
func MessageInsertPlug(m *ice.Message, zone, name, text, index, args string, arg ...string) {
|
||||
MessageInsert(m, zone, kit.Simple(mdb.TYPE, html.PLUG, mdb.NAME, kit.Select(m.ActionKey(), name), mdb.TEXT, text, ctx.INDEX, index, ctx.ARGS, args, arg)...)
|
||||
}
|
||||
|
@ -70,8 +70,17 @@ func init() {
|
||||
m.Cmdy(TASK, mdb.INSERT, arg)
|
||||
web.StreamPushRefreshConfirm(m, m.Trans("refresh for new message ", "刷新列表,查看最新消息 "))
|
||||
}},
|
||||
web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
PlanInsert(m, web.DREAM, "", "", web.CHAT_IFRAME, web.S(m.Option(mdb.NAME)))
|
||||
}},
|
||||
aaa.OFFER_CREATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
PlanInsert(m, aaa.APPLY, "", m.Option(aaa.EMAIL), aaa.OFFER, m.Option(mdb.HASH))
|
||||
}},
|
||||
aaa.OFFER_ACCEPT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
PlanInsert(m, aaa.APPLY, "", m.Option(aaa.EMAIL), aaa.OFFER, m.Option(mdb.HASH))
|
||||
}},
|
||||
aaa.USER_CREATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
PlanInsert(m, aaa.APPLY, "", m.Option(aaa.USERNAME), aaa.USER, m.Option(aaa.USERNAME))
|
||||
PlanInsert(m, aaa.APPLY, "", "", aaa.USER, m.Option(aaa.USERNAME))
|
||||
}},
|
||||
ctx.RUN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.RenameOption(TASK_POD, ice.POD); ctx.PodCmd(m, m.ShortKey(), ctx.RUN, arg) {
|
||||
@ -82,7 +91,10 @@ func init() {
|
||||
m.Cmdy(arg)
|
||||
}
|
||||
}},
|
||||
}, web.DreamTablesAction(), gdb.EventsAction(aaa.USER_CREATE, aaa.USER_REMOVE), ctx.ConfAction(mdb.TOOLS, "todo,epic", "online", ice.TRUE), TASK), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, web.DreamTablesAction(), web.DreamAction(), gdb.EventsAction(
|
||||
aaa.OFFER_CREATE, aaa.OFFER_ACCEPT,
|
||||
aaa.USER_CREATE, aaa.USER_REMOVE,
|
||||
), ctx.ConfAction(mdb.TOOLS, "todo,epic", "online", ice.TRUE), TASK), Hand: func(m *ice.Message, arg ...string) {
|
||||
begin_time, end_time := _plan_scope(m, kit.Slice(arg, 0, 2)...)
|
||||
_plan_list(m, begin_time.Format(ice.MOD_TIME), end_time.Format(ice.MOD_TIME))
|
||||
web.PushPodCmd(m, "", arg...)
|
||||
@ -92,8 +104,8 @@ func init() {
|
||||
})
|
||||
}
|
||||
func PlanInsert(m *ice.Message, zone, name, text, index, args string, arg ...string) {
|
||||
m.Cmd(PLAN, mdb.INSERT, web.SPACE, "", mdb.ZONE, zone, mdb.TYPE, "one",
|
||||
mdb.NAME, kit.Select(m.ActionKey(), name), mdb.TEXT, text, BEGIN_TIME, m.Time(),
|
||||
m.Cmd(PLAN, mdb.INSERT, web.SPACE, "", mdb.ZONE, zone, mdb.TYPE, "once",
|
||||
mdb.NAME, kit.Select(m.ActionKey(), name), mdb.TEXT, kit.Select(args, text), BEGIN_TIME, m.Time(),
|
||||
"extra.index", index, "extra.args", args, arg,
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user