0

Remove message image from go code

This commit is contained in:
Jannik Volkland 2020-10-14 13:47:39 +02:00
parent 146e6d342c
commit 606ccb6c14
4 changed files with 4 additions and 11 deletions

View File

@ -36,7 +36,6 @@ func createTable(db *sql.DB) {
"id" string NOT NULL PRIMARY KEY, "id" string NOT NULL PRIMARY KEY,
"author" TEXT, "author" TEXT,
"body" TEXT, "body" TEXT,
"image" TEXT,
"messageType" TEXT, "messageType" TEXT,
"visible" INTEGER, "visible" INTEGER,
"timestamp" DATE "timestamp" DATE
@ -51,11 +50,11 @@ func createTable(db *sql.DB) {
func addMessage(message models.ChatMessage) { func addMessage(message models.ChatMessage) {
tx, err := _db.Begin() 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 { if err != nil {
log.Fatal(err) 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 { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -78,12 +77,11 @@ func getChatHistory() []models.ChatMessage {
var id string var id string
var author string var author string
var body string var body string
var image string
var messageType string var messageType string
var visible int var visible int
var timestamp time.Time var timestamp time.Time
err = rows.Scan(&id, &author, &body, &image, &messageType, &visible, &timestamp) err = rows.Scan(&id, &author, &body, &messageType, &visible, &timestamp)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
@ -92,7 +90,6 @@ func getChatHistory() []models.ChatMessage {
message.ID = id message.ID = id
message.Author = author message.Author = author
message.Body = body message.Body = body
message.Image = image
message.MessageType = messageType message.MessageType = messageType
message.Visible = visible == 1 message.Visible = visible == 1
message.Timestamp = timestamp message.Timestamp = timestamp

View File

@ -140,7 +140,7 @@ func (s *server) sendWelcomeMessageToClient(c *Client) {
time.Sleep(7 * time.Second) time.Sleep(7 * time.Second)
initialChatMessageText := fmt.Sprintf("Welcome to %s! %s", config.Config.InstanceDetails.Title, config.Config.InstanceDetails.Summary) 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) c.Write(initialMessage)
}() }()

View File

@ -18,7 +18,6 @@ type ChatMessage struct {
Author string `json:"author"` Author string `json:"author"`
Body string `json:"body"` Body string `json:"body"`
Image string `json:"image"`
ID string `json:"id"` ID string `json:"id"`
MessageType string `json:"type"` MessageType string `json:"type"`
Visible bool `json:"visible"` Visible bool `json:"visible"`

View File

@ -307,9 +307,6 @@ paths:
body: body:
type: string type: string
description: Escaped HTML of the chat message content. description: Escaped HTML of the chat message content.
image:
type: string
description: URL of the chat user avatar.
id: id:
type: string type: string
description: Unique ID of the chat message. description: Unique ID of the chat message.