Add ability to mark a message as ephemeral and set it with title changes
This commit is contained in:
parent
8f1681c7aa
commit
4f833be80a
@ -62,16 +62,17 @@ func SetStreamTitle(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if value != "" {
|
||||
sendSystemChatAction(fmt.Sprintf("Stream title changed to **%s**", value))
|
||||
sendSystemChatAction(fmt.Sprintf("Stream title changed to **%s**", value), true)
|
||||
}
|
||||
controllers.WriteSimpleResponse(w, true, "changed")
|
||||
}
|
||||
|
||||
func sendSystemChatAction(messageText string) {
|
||||
func sendSystemChatAction(messageText string, ephemeral bool) {
|
||||
message := models.ChatEvent{}
|
||||
message.Body = messageText
|
||||
message.MessageType = models.ChatActionSent
|
||||
message.ClientID = "internal-server"
|
||||
message.Ephemeral = ephemeral
|
||||
message.SetDefaults()
|
||||
|
||||
if err := core.SendMessageToChat(message); err != nil {
|
||||
|
@ -137,7 +137,9 @@ func (s *server) Listen() {
|
||||
|
||||
// Store in the message history
|
||||
msg.SetDefaults()
|
||||
addMessage(msg)
|
||||
if !msg.Ephemeral {
|
||||
addMessage(msg)
|
||||
}
|
||||
|
||||
// Send webhooks
|
||||
go webhooks.SendChatEvent(msg)
|
||||
|
@ -24,6 +24,7 @@ type ChatEvent struct {
|
||||
MessageType EventType `json:"type"`
|
||||
Visible bool `json:"visible"`
|
||||
Timestamp time.Time `json:"timestamp,omitempty"`
|
||||
Ephemeral bool `json:"ephemeral,omitempty"`
|
||||
}
|
||||
|
||||
// Valid checks to ensure the message is valid.
|
||||
|
Loading…
x
Reference in New Issue
Block a user