From c180db8f0d36d177eced55a4f81c801bbc9d4f74 Mon Sep 17 00:00:00 2001 From: or-else Date: Mon, 1 Jan 2018 18:19:20 -0800 Subject: [PATCH] expanding plugin actions --- API.md | 7 +- pbx/model.pb.go | 305 ++++++++++++++++++++++-------------------- pbx/model.proto | 5 +- server/pbconverter.go | 177 ++++++++++++++---------- server/plugins.go | 106 ++++++++++++++- server/session.go | 2 + server/topic.go | 49 +++++-- 7 files changed, 413 insertions(+), 238 deletions(-) diff --git a/API.md b/API.md index b1b8e510d..30e15fa5f 100644 --- a/API.md +++ b/API.md @@ -91,15 +91,16 @@ The user agent `ua` is expected to follow [RFC 7231 section 5.5.3](http://tools. #### `{acc}` -Message `{acc}` creats users or updates `tags` or authentication credentials `scheme` and `secret` of exiting users. To create a new user set `user` to the string `new` optionally followed by any character sequence, e.g. `newr15gsr`. Either authenticated or anonymous session can send an `{acc}` message to create a new user. To update tags or authentication credentials of the current user leave `user` unset. +Message `{acc}` creates users or updates `tags` or authentication credentials `scheme` and `secret` of exiting users. To create a new user set `user` to the string `new` optionally followed by any character sequence, e.g. `newr15gsr`. Either authenticated or anonymous session can send an `{acc}` message to create a new user. To update tags or authentication credentials of the current user leave `user` unset. ```js acc: { id: "1a2b3", // string, client-provided message id, optional user: "new", // string, "new" to create a new user, default: current user, optional scheme: "basic", // authentication scheme for this account, required; - // "basic" and "anonymous" are currently supported for account creation. The current - // implementation of the basic scheme does not allow changes to username. + // "basic" and "anonymous" are currently supported for account creation. The + // current implementation of the basic scheme does not allow changes to + // username. secret: btoa("username:password"), // string, base64 encoded secret for the chosen // authentication scheme; to delete a scheme use a string with a single DEL // Unicode character "\u2421"; "token" and "basic" cannot be deleted diff --git a/pbx/model.pb.go b/pbx/model.pb.go index dadedf1d8..3a8d45c6f 100644 --- a/pbx/model.pb.go +++ b/pbx/model.pb.go @@ -2309,7 +2309,8 @@ func (m *SubscriptionEvent) GetSub() *TopicSub { } type MessageEvent struct { - Action Crud `protobuf:"varint,1,opt,name=action,enum=pbx.Crud" json:"action,omitempty"` + Action Crud `protobuf:"varint,1,opt,name=action,enum=pbx.Crud" json:"action,omitempty"` + Msg *ServerData `protobuf:"bytes,2,opt,name=msg" json:"msg,omitempty"` } func (m *MessageEvent) Reset() { *m = MessageEvent{} } @@ -2324,6 +2325,13 @@ func (m *MessageEvent) GetAction() Crud { return Crud_CREATE } +func (m *MessageEvent) GetMsg() *ServerData { + if m != nil { + return m.Msg + } + return nil +} + func init() { proto.RegisterType((*Unused)(nil), "pbx.Unused") proto.RegisterType((*DefaultAcsMode)(nil), "pbx.DefaultAcsMode") @@ -2480,10 +2488,10 @@ var _Node_serviceDesc = grpc.ServiceDesc{ type PluginClient interface { // This plugin method is called by Tinode server for every message received from the clients. The - // method returns a ServerCtrl message. ServerCtrl.code is *not* 0 indicates that no further + // method returns a ServerCtrl message. Non-zero ServerCtrl.code indicates that no further // processing is needed. The Tinode server will generate a {ctrl} message from the returned ServerCtrl // and forward it to the client session. - // If ServerCtrl.code is 0, the server should continue with default processing of the client message. + // ServerCtrl.code equals to 0 instructs the server to continue with default processing of the client message. FireHose(ctx context.Context, in *ClientReq, opts ...grpc.CallOption) (*ServerResp, error) // Account created, updated or deleted Account(ctx context.Context, in *AccountEvent, opts ...grpc.CallOption) (*Unused, error) @@ -2552,10 +2560,10 @@ func (c *pluginClient) Message(ctx context.Context, in *MessageEvent, opts ...gr type PluginServer interface { // This plugin method is called by Tinode server for every message received from the clients. The - // method returns a ServerCtrl message. ServerCtrl.code is *not* 0 indicates that no further + // method returns a ServerCtrl message. Non-zero ServerCtrl.code indicates that no further // processing is needed. The Tinode server will generate a {ctrl} message from the returned ServerCtrl // and forward it to the client session. - // If ServerCtrl.code is 0, the server should continue with default processing of the client message. + // ServerCtrl.code equals to 0 instructs the server to continue with default processing of the client message. FireHose(context.Context, *ClientReq) (*ServerResp, error) // Account created, updated or deleted Account(context.Context, *AccountEvent) (*Unused, error) @@ -2693,147 +2701,148 @@ var _Plugin_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("model.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 2266 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0xcd, 0x6f, 0xdb, 0xc8, - 0x15, 0xb7, 0x44, 0x91, 0x22, 0x9f, 0xb4, 0x36, 0x33, 0x75, 0xb3, 0x5a, 0x2f, 0xb2, 0x71, 0x98, - 0x34, 0x1b, 0x38, 0xbb, 0xee, 0x36, 0x69, 0xda, 0xed, 0xc7, 0x45, 0xb1, 0x14, 0xdb, 0x8d, 0x6d, - 0xa9, 0x94, 0x9d, 0x02, 0x45, 0x01, 0x81, 0x22, 0xc7, 0x12, 0xb1, 0x34, 0x29, 0x93, 0x43, 0x25, - 0x01, 0x8a, 0xde, 0x7a, 0x68, 0xff, 0x83, 0xa2, 0xf7, 0x5e, 0xda, 0x02, 0xfd, 0x3b, 0xda, 0x6b, - 0x2f, 0xfd, 0x33, 0x7a, 0xef, 0xa1, 0x78, 0x33, 0xc3, 0x4f, 0xc7, 0x59, 0xf7, 0xe3, 0x22, 0xcc, - 0xbc, 0xf7, 0xf4, 0xe6, 0x7d, 0xcd, 0xef, 0x3d, 0x0e, 0x74, 0x2e, 0x22, 0x8f, 0x06, 0xbb, 0xcb, - 0x38, 0x62, 0x11, 0x51, 0x96, 0xb3, 0x37, 0x96, 0x0e, 0xda, 0x59, 0x98, 0x26, 0xd4, 0xb3, 0xbe, - 0x84, 0xf5, 0x01, 0x3d, 0x77, 0xd2, 0x80, 0xf5, 0xdd, 0xe4, 0x38, 0xf2, 0x28, 0x21, 0xd0, 0x72, - 0x52, 0xb6, 0xe8, 0x35, 0xb6, 0x1b, 0x8f, 0x0c, 0x9b, 0xaf, 0x39, 0x2d, 0x8c, 0xc2, 0x5e, 0x53, - 0xd2, 0xc2, 0x28, 0xb4, 0xbe, 0x07, 0xd0, 0x77, 0x5d, 0x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d9, 0x00, 0x6d, 0x1c, 0xa4, 0xf8, 0xe5, 0xf8, - 0x39, 0xe8, 0x2f, 0xfc, 0x98, 0x1e, 0x44, 0x09, 0xad, 0xfc, 0xd9, 0xa6, 0x97, 0x5b, 0x1b, 0x35, - 0x68, 0xb2, 0xd6, 0xc8, 0x63, 0x68, 0xcb, 0xda, 0x20, 0xb7, 0xb2, 0x96, 0x9a, 0x57, 0xca, 0x96, - 0x78, 0x4d, 0x94, 0x4f, 0xdc, 0x6b, 0xe4, 0x53, 0x50, 0x79, 0xec, 0xc8, 0x46, 0x11, 0xc7, 0x77, - 0x0a, 0x3e, 0x83, 0x6e, 0x39, 0x87, 0x44, 0xa2, 0x41, 0x3d, 0xad, 0xf5, 0xbf, 0x3d, 0xce, 0x41, - 0x56, 0x1a, 0x53, 0x4e, 0x4c, 0x4d, 0x78, 0xa6, 0xf1, 0x77, 0xf8, 0xa7, 0xff, 0x0e, 0x00, 0x00, - 0xff, 0xff, 0xd8, 0xa4, 0xd5, 0xc8, 0x96, 0x17, 0x00, 0x00, + // 2275 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0x4b, 0x73, 0xdb, 0xc8, + 0xf1, 0x17, 0x09, 0x02, 0x04, 0x9a, 0xb4, 0x04, 0xcf, 0x5f, 0x7f, 0x2f, 0x57, 0x5b, 0x5e, 0xcb, + 0xb0, 0xe3, 0x75, 0xc9, 0xbb, 0xca, 0x96, 0x1d, 0x27, 0x9b, 0xc7, 0x85, 0x16, 0x69, 0x49, 0xb1, + 0x24, 0x32, 0xa0, 0xe4, 0x54, 0xa5, 0x52, 0xc5, 0x02, 0x81, 0x11, 0x89, 0x5a, 0x08, 0xa0, 0x80, + 0x01, 0x6d, 0x57, 0xa5, 0x72, 0xcb, 0x21, 0xf9, 0x06, 0xa9, 0xdc, 0x73, 0x49, 0x52, 0x95, 0xcf, + 0x91, 0x5c, 0x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0xa2, 0x6d, 0x92, 0xce, + 0x50, 0x1b, 0xb6, 0x12, 0xd4, 0x86, 0x17, 0x93, 0x87, 0xb3, 0xa6, 0x0d, 0xe9, 0x5c, 0x1b, 0xbf, + 0xb9, 0x16, 0x28, 0xcb, 0x74, 0xc6, 0x03, 0x5c, 0xd5, 0x36, 0x16, 0xda, 0x96, 0xe9, 0x0c, 0x65, + 0xe6, 0x94, 0x49, 0xa0, 0x2b, 0xcb, 0xec, 0x53, 0x86, 0x32, 0x73, 0xca, 0xb8, 0x55, 0x94, 0xf5, + 0xf4, 0xab, 0x56, 0x09, 0x99, 0x44, 0xc8, 0x78, 0x34, 0xe8, 0x19, 0x57, 0x64, 0x06, 0x34, 0x40, + 0x19, 0x8f, 0x06, 0xe4, 0x5b, 0xd0, 0x0a, 0x23, 0x46, 0x7b, 0x50, 0x6a, 0x82, 0x45, 0x26, 0x0f, + 0xd6, 0x6c, 0xce, 0x7e, 0x61, 0x40, 0xfb, 0x98, 0x26, 0x89, 0x33, 0xa7, 0xd6, 0x1f, 0x9a, 0x60, + 0x9c, 0x62, 0x42, 0x07, 0xa2, 0xe3, 0x81, 0x1b, 0x53, 0x87, 0x51, 0x6f, 0x2a, 0x1b, 0xb4, 0x62, + 0x1b, 0x92, 0xd2, 0x67, 0xbc, 0x4f, 0x2d, 0xbd, 0x8c, 0xdd, 0x14, 0x6c, 0x49, 0xe9, 0x33, 0xf2, + 0x04, 0x34, 0x1c, 0x67, 0xdc, 0x44, 0xa6, 0xe1, 0xbd, 0x13, 0x8f, 0x14, 0x21, 0xf7, 0x31, 0xad, + 0x49, 0xa5, 0x5d, 0x17, 0xd3, 0x1a, 0x66, 0x35, 0x29, 0xd5, 0x8f, 0x5a, 0xaa, 0x1f, 0xac, 0xf7, + 0x98, 0x3a, 0x1e, 0xd2, 0x35, 0x4e, 0xd7, 0x70, 0x9b, 0x31, 0xdc, 0x15, 0x32, 0xda, 0x19, 0xc3, + 0x5d, 0x1d, 0x7a, 0xa8, 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0x00, 0x00, 0x00, 0xff, 0xff, 0xa7, 0x0e, 0xa1, 0x0a, 0xb9, + 0x17, 0x00, 0x00, } diff --git a/pbx/model.proto b/pbx/model.proto index a8051d991..895e3ab1f 100644 --- a/pbx/model.proto +++ b/pbx/model.proto @@ -10,10 +10,10 @@ service Node { // Plugin interface. service Plugin { // This plugin method is called by Tinode server for every message received from the clients. The - // method returns a ServerCtrl message. ServerCtrl.code is *not* 0 indicates that no further + // method returns a ServerCtrl message. Non-zero ServerCtrl.code indicates that no further // processing is needed. The Tinode server will generate a {ctrl} message from the returned ServerCtrl // and forward it to the client session. - // If ServerCtrl.code is 0, the server should continue with default processing of the client message. + // ServerCtrl.code equals to 0 instructs the server to continue with default processing of the client message. rpc FireHose(ClientReq) returns (ServerResp) {} // The following methods are for the Tinode server to report individual events. @@ -439,4 +439,5 @@ message SubscriptionEvent { message MessageEvent { Crud action = 1; + ServerData msg = 2; } diff --git a/server/pbconverter.go b/server/pbconverter.go index b9347d81a..3cb8639e7 100644 --- a/server/pbconverter.go +++ b/server/pbconverter.go @@ -10,85 +10,106 @@ import ( "github.com/tinode/chat/pbx" ) +func pb_serv_ctrl_serialize(ctrl *MsgServerCtrl) *pbx.ServerMsg_Ctrl { + var params map[string][]byte + if ctrl.Params != nil { + if in, ok := ctrl.Params.(map[string]interface{}); ok { + params = interfaceMapToByteMap(in) + } + } + + return &pbx.ServerMsg_Ctrl{Ctrl: &pbx.ServerCtrl{ + Id: ctrl.Id, + Topic: ctrl.Topic, + Code: int32(ctrl.Code), + Text: ctrl.Text, + Params: params}} +} + +func pb_serv_data_serialize(data *MsgServerData) *pbx.ServerMsg_Data { + return &pbx.ServerMsg_Data{Data: &pbx.ServerData{ + Topic: data.Topic, + FromUserId: data.From, + DeletedAt: timeToInt64(data.DeletedAt), + SeqId: int32(data.SeqId), + Head: data.Head, + Content: interfaceToBytes(data.Content)}} +} + +func pb_serv_pres_serialize(pres *MsgServerPres) *pbx.ServerMsg_Pres { + var what pbx.ServerPres_What + switch pres.What { + case "on": + what = pbx.ServerPres_ON + case "off": + what = pbx.ServerPres_OFF + case "ua": + what = pbx.ServerPres_UA + case "upd": + what = pbx.ServerPres_UPD + case "gone": + what = pbx.ServerPres_GONE + case "acs": + what = pbx.ServerPres_ACS + case "term": + what = pbx.ServerPres_TERM + case "msg": + what = pbx.ServerPres_MSG + case "read": + what = pbx.ServerPres_READ + case "recv": + what = pbx.ServerPres_RECV + case "del": + what = pbx.ServerPres_DEL + default: + log.Fatal("Unknown pres.what value", pres.What) + } + return &pbx.ServerMsg_Pres{Pres: &pbx.ServerPres{ + Topic: pres.Topic, + Src: pres.Src, + What: what, + UserAgent: pres.UserAgent, + SeqId: int32(pres.SeqId), + DelId: int32(pres.DelId), + DelSeq: pb_DelQuery_serialize(pres.DelSeq), + TargetUserId: pres.AcsTarget, + ActorUserId: pres.AcsActor, + Acs: pb_AccessMode_serialize(pres.Acs)}} +} + +func pb_serv_info_serialize(info *MsgServerInfo) *pbx.ServerMsg_Info { + return &pbx.ServerMsg_Info{Info: &pbx.ServerInfo{ + Topic: info.Topic, + FromUserId: info.From, + What: pb_InfoNoteWhat_serialize(info.What), + SeqId: int32(info.SeqId), + }} +} + +func pb_serv_meta_serialize(meta *MsgServerMeta) *pbx.ServerMsg_Meta { + return &pbx.ServerMsg_Meta{Meta: &pbx.ServerMeta{ + Id: meta.Id, + Topic: meta.Topic, + Desc: pb_TopicDesc_serialize(meta.Desc), + Sub: pb_TopicSubSlice_serialize(meta.Sub), + Del: pb_DelValues_serialize(meta.Del), + }} +} + // Convert ServerComMessage to pbx.ServerMsg func pb_serv_serialize(msg *ServerComMessage) *pbx.ServerMsg { var pkt pbx.ServerMsg if msg.Ctrl != nil { - var params map[string][]byte - if msg.Ctrl.Params != nil { - if in, ok := msg.Ctrl.Params.(map[string]interface{}); ok { - params = interfaceMapToByteMap(in) - } - } - pkt.Message = &pbx.ServerMsg_Ctrl{Ctrl: &pbx.ServerCtrl{ - Id: msg.Ctrl.Id, - Topic: msg.Ctrl.Topic, - Code: int32(msg.Ctrl.Code), - Text: msg.Ctrl.Text, - Params: params}} + pkt.Message = pb_serv_ctrl_serialize(msg.Ctrl) } else if msg.Data != nil { - pkt.Message = &pbx.ServerMsg_Data{Data: &pbx.ServerData{ - Topic: msg.Data.Topic, - FromUserId: msg.Data.From, - DeletedAt: timeToInt64(msg.Data.DeletedAt), - SeqId: int32(msg.Data.SeqId), - Head: msg.Data.Head, - Content: interfaceToBytes(msg.Data.Content)}} + pkt.Message = pb_serv_data_serialize(msg.Data) } else if msg.Pres != nil { - var what pbx.ServerPres_What - switch msg.Pres.What { - case "on": - what = pbx.ServerPres_ON - case "off": - what = pbx.ServerPres_OFF - case "ua": - what = pbx.ServerPres_UA - case "upd": - what = pbx.ServerPres_UPD - case "gone": - what = pbx.ServerPres_GONE - case "acs": - what = pbx.ServerPres_ACS - case "term": - what = pbx.ServerPres_TERM - case "msg": - what = pbx.ServerPres_MSG - case "read": - what = pbx.ServerPres_READ - case "recv": - what = pbx.ServerPres_RECV - case "del": - what = pbx.ServerPres_DEL - default: - log.Fatal("Unknown pres.what value", msg.Pres.What) - } - pkt.Message = &pbx.ServerMsg_Pres{Pres: &pbx.ServerPres{ - Topic: msg.Pres.Topic, - Src: msg.Pres.Src, - What: what, - UserAgent: msg.Pres.UserAgent, - SeqId: int32(msg.Pres.SeqId), - DelId: int32(msg.Pres.DelId), - DelSeq: pb_DelQuery_serialize(msg.Pres.DelSeq), - TargetUserId: msg.Pres.AcsTarget, - ActorUserId: msg.Pres.AcsActor, - Acs: pb_AccessMode_serialize(msg.Pres.Acs)}} + pkt.Message = pb_serv_pres_serialize(msg.Pres) } else if msg.Info != nil { - pkt.Message = &pbx.ServerMsg_Info{Info: &pbx.ServerInfo{ - Topic: msg.Info.Topic, - FromUserId: msg.Info.From, - What: pb_InfoNoteWhat_serialize(msg.Info.What), - SeqId: int32(msg.Info.SeqId), - }} + pkt.Message = pb_serv_info_serialize(msg.Info) } else if msg.Meta != nil { - pkt.Message = &pbx.ServerMsg_Meta{Meta: &pbx.ServerMeta{ - Id: msg.Meta.Id, - Topic: msg.Meta.Topic, - Desc: pb_TopicDesc_serialize(msg.Meta.Desc), - Sub: pb_TopicSubSlice_serialize(msg.Meta.Sub), - Del: pb_DelValues_serialize(msg.Meta.Del), - }} + pkt.Message = pb_serv_meta_serialize(msg.Meta) } return &pkt @@ -631,6 +652,22 @@ func pb_TopicDesc_deserialize(desc *pbx.TopicDesc) *MsgTopicDesc { } } +func pb_Topic_serialize(topic *Topic) *pbx.TopicDesc { + if topic == nil { + return nil + } + return &pbx.TopicDesc{ + CreatedAt: timeToInt64(&topic.created), + UpdatedAt: timeToInt64(&topic.updated), + Defacs: &pbx.DefaultAcsMode{ + Auth: topic.accessAuth.String(), + Anon: topic.accessAnon.String()}, + SeqId: int32(topic.lastId), + DelId: int32(topic.delId), + Public: interfaceToBytes(topic.public), + } +} + func pb_TopicSubSlice_serialize(subs []MsgTopicSub) []*pbx.TopicSub { if subs == nil || len(subs) == 0 { return nil diff --git a/server/plugins.go b/server/plugins.go index f18e5270d..a11d4d347 100644 --- a/server/plugins.go +++ b/server/plugins.go @@ -334,8 +334,7 @@ func pluginFireHose(sess *Session, msg *ClientComMessage) (*ClientComMessage, *S var req *pbx.ClientReq - var id string - var topic string + id, topic := pluginIdAndTopic(msg) ts := time.Now().UTC().Round(time.Millisecond) for _, p := range plugins { if !pluginDoFiltering(p.filterFireHose, msg) { @@ -429,16 +428,77 @@ func pluginAccount(user *types.User, action int) { } } -func pluginTopic(msg *ServerComMessage) *ServerComMessage { - return nil +func pluginTopic(topic *Topic, action int) { + if plugins == nil { + return + } + + var event *pbx.TopicEvent + for _, p := range plugins { + if p.filterTopic == nil || p.filterTopic.byAction&action == 0 { + // Plugin is not interested in Message actions + continue + } + + if event == nil { + event = &pbx.TopicEvent{ + Action: pluginActionToCrud(action), + Name: topic.name, + Desc: pb_Topic_serialize(topic), + } + } + + var ctx context.Context + var cancel context.CancelFunc + if p.timeout > 0 { + ctx, cancel = context.WithTimeout(context.Background(), p.timeout) + defer cancel() + } else { + ctx = context.Background() + } + if _, err := p.client.Topic(ctx, event); err != nil { + log.Println("plugins: Topic call failed", p.name, err) + } + } + + return } func pluginSubscription(msg *ServerComMessage) *ServerComMessage { return nil } -func pluginMessage(msg *ServerComMessage) *ServerComMessage { - return nil +func pluginMessage(data *MsgServerData, action int) { + if plugins == nil || action != plgActCreate { + return + } + + var event *pbx.MessageEvent + for _, p := range plugins { + if p.filterMessage == nil || p.filterMessage.byAction&action == 0 { + // Plugin is not interested in Message actions + continue + } + + if event == nil { + event = &pbx.MessageEvent{ + Action: pluginActionToCrud(action), + Msg: pb_serv_data_serialize(data).Data, + } + } + + var ctx context.Context + var cancel context.CancelFunc + if p.timeout > 0 { + ctx, cancel = context.WithTimeout(context.Background(), p.timeout) + defer cancel() + } else { + ctx = context.Background() + } + if _, err := p.client.Message(ctx, event); err != nil { + log.Println("plugins: Message call failed", p.name, err) + } + } } // Returns false to skip, true to process @@ -515,3 +575,37 @@ func pluginActionToCrud(action int) pbx.Crud { } panic("plugin: unknown action") } + +func pluginIdAndTopic(msg *ClientComMessage) (string, string) { + if msg.Hi != nil { + return msg.Hi.Id, "" + } + if msg.Acc != nil { + return msg.Acc.Id, "" + } + if msg.Login != nil { + return msg.Login.Id, "" + } + if msg.Sub != nil { + return msg.Sub.Id, msg.Sub.Topic + } + if msg.Leave != nil { + return msg.Leave.Id, msg.Leave.Topic + } + if msg.Pub != nil { + return msg.Pub.Id, msg.Pub.Topic + } + if msg.Get != nil { + return msg.Get.Id, msg.Get.Topic + } + if msg.Set != nil { + return msg.Set.Id, msg.Set.Topic + } + if msg.Del != nil { + return msg.Del.Id, msg.Del.Topic + } + if msg.Note != nil { + return "", msg.Note.Topic + } + panic("plugin: unknown message") +} diff --git a/server/session.go b/server/session.go index e17d0bd19..9e66f77e1 100644 --- a/server/session.go +++ b/server/session.go @@ -674,6 +674,8 @@ func (s *Session) acc(msg *ClientComMessage) { s.queueOut(NoErr(msg.Acc.Id, "", msg.timestamp)) + // pluginAccount(&user, plgActCreate) + } else { // session is not authenticated and this is not an attempt to create a new account s.queueOut(ErrPermissionDenied(msg.Acc.Id, "", msg.timestamp)) diff --git a/server/topic.go b/server/topic.go index 3d8222b7b..857cf4da5 100644 --- a/server/topic.go +++ b/server/topic.go @@ -191,6 +191,11 @@ func (t *Topic) run(hub *Hub) { // while processing the call killTimer.Stop() if err := t.handleSubscription(hub, sreg); err == nil { + if sreg.created { + // Call plugins with the new topic + pluginTopic(t, plgActCreate) + } + // give a broadcast channel to the connection (.read) // give channel to use when shutting down (.done) sreg.sess.subs[t.name] = &Subscription{ @@ -316,6 +321,9 @@ func (t *Topic) run(hub *Hub) { // Message sent: notify offline 'R' subscrbers on 'me' t.presSubsOffline("msg", &PresParams{seqId: t.lastId}, types.ModeRead, "", true) + // Tell the plugins that a message was accepted for delivery + pluginMessage(msg.Data, plgActCreate) + } else if msg.Pres != nil { what := t.presProcReq(msg.Pres.Src, msg.Pres.What, msg.Pres.wantReply) @@ -467,36 +475,56 @@ func (t *Topic) run(hub *Hub) { if meta.pkt.Get != nil { // Get request if meta.what&constMsgMetaDesc != 0 { - t.replyGetDesc(meta.sess, meta.pkt.Get.Id, "", meta.pkt.Get.Desc) + if err := t.replyGetDesc(meta.sess, meta.pkt.Get.Id, "", meta.pkt.Get.Desc); err != nil { + log.Printf("topic[%s] meta.Get.Desc failed: %v", t.name, err) + } } if meta.what&constMsgMetaSub != 0 { - t.replyGetSub(meta.sess, meta.pkt.Get.Id, meta.pkt.Get.Sub) + if err := t.replyGetSub(meta.sess, meta.pkt.Get.Id, meta.pkt.Get.Sub); err != nil { + log.Printf("topic[%s] meta.Get.Sub failed: %v", t.name, err) + } } if meta.what&constMsgMetaData != 0 { - t.replyGetData(meta.sess, meta.pkt.Get.Id, meta.pkt.Get.Data) + if err := t.replyGetData(meta.sess, meta.pkt.Get.Id, meta.pkt.Get.Data); err != nil { + log.Printf("topic[%s] meta.Get.Data failed: %v", t.name, err) + } } if meta.what&constMsgMetaDel != 0 { - t.replyGetDel(meta.sess, meta.pkt.Get.Id, meta.pkt.Get.Del) + if err := t.replyGetDel(meta.sess, meta.pkt.Get.Id, meta.pkt.Get.Del); err != nil { + log.Printf("topic[%s] meta.Get.Del failed: %v", t.name, err) + } } } else if meta.pkt.Set != nil { // Set request if meta.what&constMsgMetaDesc != 0 { - t.replySetDesc(meta.sess, meta.pkt.Set) + if err := t.replySetDesc(meta.sess, meta.pkt.Set); err == nil { + // Notify plugins of the update + pluginTopic(t, plgActUpd) + } else { + log.Printf("topic[%s] meta.Set.Desc failed: %v", t.name, err) + } } if meta.what&constMsgMetaSub != 0 { - t.replySetSub(hub, meta.sess, meta.pkt.Set) + if err := t.replySetSub(hub, meta.sess, meta.pkt.Set); err != nil { + log.Printf("topic[%s] meta.Set.Sub failed: %v", t.name, err) + } } } else if meta.pkt.Del != nil { // Del request + var err error switch meta.what { case constMsgDelMsg: - t.replyDelMsg(meta.sess, meta.pkt.Del) + err = t.replyDelMsg(meta.sess, meta.pkt.Del) case constMsgDelSub: - t.replyDelSub(hub, meta.sess, meta.pkt.Del) + err = t.replyDelSub(hub, meta.sess, meta.pkt.Del) case constMsgDelTopic: - t.replyDelTopic(hub, meta.sess, meta.pkt.Del) + err = t.replyDelTopic(hub, meta.sess, meta.pkt.Del) + } + + if err != nil { + log.Printf("topic[%s] meta.Del failed: %v", t.name, err) } } case ua := <-t.uaChange: @@ -537,6 +565,9 @@ func (t *Topic) run(hub *Hub) { } // P2P users get "off+remove" earlier in the process + // Inform plugins that the topic is deleted + pluginTopic(t, plgActDel) + } else if sd.reason == StopRehashing { // Must send individual messages to sessions because normal sending through the topic's // broadcast channel won't work - it will be shut down too soon.