mirror of
https://shylinux.com/x/community
synced 2025-07-03 05:51:20 +08:00
66 lines
2.4 KiB
Go
66 lines
2.4 KiB
Go
package gonganxitong
|
|
|
|
import (
|
|
"shylinux.com/x/ice"
|
|
"shylinux.com/x/icebergs/base/aaa"
|
|
"shylinux.com/x/icebergs/base/web"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/community/src/gonganxitong/model"
|
|
)
|
|
|
|
type sess struct {
|
|
Table
|
|
user user
|
|
fields string `data:"user_uid,agent,system,location,ip,ua"`
|
|
create string `name:"create user_uid*"`
|
|
check string `name:"check" role:"void"`
|
|
list string `name:"list uid auto" role:"void"`
|
|
}
|
|
|
|
func (s sess) Create(m *ice.Message, arg ...string) {
|
|
s.Insert(m, kit.Simple(model.USER_UID, m.Option(model.USER_UID),
|
|
m.Options(web.ParseUA(m.Message)).OptionSimple(model.IP, model.UA, model.AGENT, model.SYSTEM),
|
|
model.LOCATION, kit.Format(web.PublicIP(m.Message, m.Option(ice.MSG_USERIP))))...)
|
|
m.ProcessCookie(ice.MSG_SESSID, m.Option(ice.MSG_SESSID, kit.JoinWord(web.SPACE, m.Option(ice.MSG_USERPOD), m.PrefixKey(), aaa.CHECK, m.Result())), "-2")
|
|
}
|
|
func (s sess) List(m *ice.Message, arg ...string) {
|
|
if len(arg) == 0 {
|
|
if m.IsTech() {
|
|
s.Tables(m, user{}).FieldsWithCreatedAT(m, s, kit.Split("user_uid,name,info,avatar,background,agent,system,location,ip,ua")).Limit(m, 3000)
|
|
s.Select(m, arg...).PushAction(s.Remove).Action(s.Repair)
|
|
}
|
|
} else {
|
|
s.SelectDetail(m, s.Key(s, model.UID), arg[0])
|
|
}
|
|
}
|
|
func (s sess) Check(m *ice.Message, arg ...string) {
|
|
msg := s.Select(m.Spawn(), model.UID, arg[0])
|
|
msg = m.Cmd(s.user, s.Select, model.UID, msg.Append(model.USER_UID))
|
|
m.Option(ice.MSG_USERROLE, aaa.VOID)
|
|
m.Option(ice.MSG_USERNAME, msg.Append(model.UID))
|
|
m.Option(ice.MSG_USERNICK, msg.Append(model.NAME))
|
|
m.Option(ice.MSG_LANGUAGE, msg.Append(model.LANGUAGE))
|
|
m.Option(ice.MSG_AVATAR, msg.Append(model.AVATAR))
|
|
m.Option(ice.MSG_USERUID, msg.Append(model.UID))
|
|
m.OptionDefault(model.USER_UID, msg.Append(model.UID))
|
|
m.Option("user.status", msg.Append(model.STATUS))
|
|
}
|
|
func (s sess) Repair(m *ice.Message, arg ...string) {
|
|
m.Cmdy("").Table(func(value ice.Maps) {
|
|
if false {
|
|
s.Update(m, kit.Dict(model.LOCATION, kit.Format(web.PublicIP(m.Message, value[model.IP]))), model.UID, value[model.UID])
|
|
m.Sleep("100ms")
|
|
return
|
|
}
|
|
if value["ua"] != "" {
|
|
msg := m.Spawn()
|
|
msg.Option(ice.MSG_USERIP, value["ip"])
|
|
msg.Option(ice.MSG_USERUA, value["ua"])
|
|
s.Update(m, msg.Options(web.ParseUA(msg.Message)).OptionSimple(model.AGENT, model.SYSTEM), model.UID, value[model.UID])
|
|
}
|
|
})
|
|
}
|
|
|
|
func init() { ice.TeamCtxCmd(sess{}) }
|