Remove panic when sending message if GetSessionOwner() returns nil

This commit is contained in:
Tulir Asokan 2018-03-23 17:45:58 +02:00
parent 7dc773c990
commit 76cfbecc09

View File

@ -251,7 +251,10 @@ func (view *RoomView) NewMessage(id, sender, msgtype, text string, timestamp tim
func (view *RoomView) NewTempMessage(msgtype, text string) *types.Message { func (view *RoomView) NewTempMessage(msgtype, text string) *types.Message {
now := time.Now() now := time.Now()
id := strconv.FormatInt(now.UnixNano(), 10) id := strconv.FormatInt(now.UnixNano(), 10)
sender := view.Room.GetSessionOwner().DisplayName sender := ""
if ownerMember := view.Room.GetSessionOwner(); ownerMember != nil {
sender = ownerMember.DisplayName
}
message := view.NewMessage(id, sender, msgtype, text, now) message := view.NewMessage(id, sender, msgtype, text, now)
message.State = types.MessageStateSending message.State = types.MessageStateSending
view.AddMessage(message, AppendMessage) view.AddMessage(message, AppendMessage)