From 606ccb6c1442f909d9b1a6b72082d0b5991d112c Mon Sep 17 00:00:00 2001 From: Jannik Volkland Date: Wed, 14 Oct 2020 13:47:39 +0200 Subject: [PATCH] Remove message image from go code --- core/chat/persistence.go | 9 +++------ core/chat/server.go | 2 +- models/chatMessage.go | 1 - openapi.yaml | 3 --- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/core/chat/persistence.go b/core/chat/persistence.go index 317ef4664..14958689e 100644 --- a/core/chat/persistence.go +++ b/core/chat/persistence.go @@ -36,7 +36,6 @@ func createTable(db *sql.DB) { "id" string NOT NULL PRIMARY KEY, "author" TEXT, "body" TEXT, - "image" TEXT, "messageType" TEXT, "visible" INTEGER, "timestamp" DATE @@ -51,11 +50,11 @@ func createTable(db *sql.DB) { func addMessage(message models.ChatMessage) { tx, err := _db.Begin() - stmt, err := tx.Prepare("INSERT INTO messages(id, author, body, image, messageType, visible, timestamp) values(?, ?, ?, ?, ?, ?, ?)") + stmt, err := tx.Prepare("INSERT INTO messages(id, author, body, messageType, visible, timestamp) values(?, ?, ?, ?, ?, ?)") if err != nil { log.Fatal(err) } - _, err = stmt.Exec(message.ID, message.Author, message.Body, message.Image, message.MessageType, 1, message.Timestamp) + _, err = stmt.Exec(message.ID, message.Author, message.Body, message.MessageType, 1, message.Timestamp) if err != nil { log.Fatal(err) } @@ -78,12 +77,11 @@ func getChatHistory() []models.ChatMessage { var id string var author string var body string - var image string var messageType string var visible int var timestamp time.Time - err = rows.Scan(&id, &author, &body, &image, &messageType, &visible, ×tamp) + err = rows.Scan(&id, &author, &body, &messageType, &visible, ×tamp) if err != nil { log.Fatal(err) } @@ -92,7 +90,6 @@ func getChatHistory() []models.ChatMessage { message.ID = id message.Author = author message.Body = body - message.Image = image message.MessageType = messageType message.Visible = visible == 1 message.Timestamp = timestamp diff --git a/core/chat/server.go b/core/chat/server.go index 87b311864..ad70972d5 100644 --- a/core/chat/server.go +++ b/core/chat/server.go @@ -140,7 +140,7 @@ func (s *server) sendWelcomeMessageToClient(c *Client) { time.Sleep(7 * time.Second) initialChatMessageText := fmt.Sprintf("Welcome to %s! %s", config.Config.InstanceDetails.Title, config.Config.InstanceDetails.Summary) - initialMessage := models.ChatMessage{"owncast-server", config.Config.InstanceDetails.Name, initialChatMessageText, config.Config.InstanceDetails.Logo.Small, "initial-message-1", "CHAT", true, time.Now()} + initialMessage := models.ChatMessage{"owncast-server", config.Config.InstanceDetails.Name, initialChatMessageText, "initial-message-1", "CHAT", true, time.Now()} c.Write(initialMessage) }() diff --git a/models/chatMessage.go b/models/chatMessage.go index 5080c2669..af65b385d 100644 --- a/models/chatMessage.go +++ b/models/chatMessage.go @@ -18,7 +18,6 @@ type ChatMessage struct { Author string `json:"author"` Body string `json:"body"` - Image string `json:"image"` ID string `json:"id"` MessageType string `json:"type"` Visible bool `json:"visible"` diff --git a/openapi.yaml b/openapi.yaml index 8ab5692da..3ee81ec63 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -307,9 +307,6 @@ paths: body: type: string description: Escaped HTML of the chat message content. - image: - type: string - description: URL of the chat user avatar. id: type: string description: Unique ID of the chat message.