Remove panic when sending message if GetSessionOwner() returns nil
This commit is contained in:
parent
7dc773c990
commit
76cfbecc09
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user