]> Sergey Matveev's repositories - mmc.git/commitdiff
Channel name can be missing
authorSergey Matveev <stargrave@stargrave.org>
Mon, 13 Mar 2023 09:57:41 +0000 (12:57 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 13 Mar 2023 09:57:41 +0000 (12:57 +0300)
cmd/mmc/main.go

index 01b7d32d89408a2f69ce2234ee16f25521b31b88..f3faa860dcd223a08dde9535eba9885da22cb6a9 100644 (file)
@@ -500,10 +500,10 @@ func main() {
                                if e == nil || !e.IsValid() {
                                        continue
                                }
-                               data := e.GetData()
                                if DebugFd != nil {
-                                       spew.Fdump(DebugFd, e.EventType(), data)
+                                       spew.Fdump(DebugFd, e)
                                }
+                               data := e.GetData()
                                var user *model.User
                                if userId, ok := data["user_id"]; ok && userId.(string) != "" {
                                        user = Users[userId.(string)]
@@ -520,7 +520,10 @@ func main() {
                                case model.WebsocketEventPostEdited,
                                        model.WebsocketEventPostDeleted,
                                        model.WebsocketEventPosted:
-                                       chName := data["channel_name"].(string)
+                                       chName, ok := data["channel_name"].(string)
+                                       if !ok {
+                                               continue
+                                       }
                                        var post model.Post
                                        if err = json.NewDecoder(
                                                strings.NewReader(data["post"].(string)),