Fix SIGSEGV when a message sender is nil
This commit is contained in:
parent
3cdb625c5e
commit
2bd15ce6f2
|
@ -252,13 +252,15 @@ func (c *Client) formatMessage(chatID int64, messageID int64, preview bool, mess
|
||||||
|
|
||||||
var str strings.Builder
|
var str strings.Builder
|
||||||
var senderId int64
|
var senderId int64
|
||||||
switch message.SenderId.MessageSenderType() {
|
if message.SenderId != nil {
|
||||||
case client.TypeMessageSenderUser:
|
switch message.SenderId.MessageSenderType() {
|
||||||
senderUser, _ := message.SenderId.(*client.MessageSenderUser)
|
case client.TypeMessageSenderUser:
|
||||||
senderId = senderUser.UserId
|
senderUser, _ := message.SenderId.(*client.MessageSenderUser)
|
||||||
case client.TypeMessageSenderChat:
|
senderId = senderUser.UserId
|
||||||
senderChat, _ := message.SenderId.(*client.MessageSenderChat)
|
case client.TypeMessageSenderChat:
|
||||||
senderId = senderChat.ChatId
|
senderChat, _ := message.SenderId.(*client.MessageSenderChat)
|
||||||
|
senderId = senderChat.ChatId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
str.WriteString(fmt.Sprintf("%v | %s | ", message.Id, c.formatContact(senderId)))
|
str.WriteString(fmt.Sprintf("%v | %s | ", message.Id, c.formatContact(senderId)))
|
||||||
if !preview {
|
if !preview {
|
||||||
|
|
Loading…
Reference in a new issue