Fix SIGSEGV when a message sender is nil

This commit is contained in:
Bohdan Horbeshko 2022-01-31 19:58:50 -05:00
parent 3cdb625c5e
commit 2bd15ce6f2

View file

@ -252,6 +252,7 @@ func (c *Client) formatMessage(chatID int64, messageID int64, preview bool, mess
var str strings.Builder
var senderId int64
if message.SenderId != nil {
switch message.SenderId.MessageSenderType() {
case client.TypeMessageSenderUser:
senderUser, _ := message.SenderId.(*client.MessageSenderUser)
@ -260,6 +261,7 @@ func (c *Client) formatMessage(chatID int64, messageID int64, preview bool, mess
senderChat, _ := message.SenderId.(*client.MessageSenderChat)
senderId = senderChat.ChatId
}
}
str.WriteString(fmt.Sprintf("%v | %s | ", message.Id, c.formatContact(senderId)))
if !preview {
str.WriteString(