Fix chat creation with non-contact users

This commit is contained in:
Jaidyn Ann 2021-08-15 20:34:30 -05:00
parent 4da76e0256
commit b380b6115c
2 changed files with 19 additions and 12 deletions

View File

@ -444,11 +444,9 @@ Server::ImMessage(BMessage* msg)
} }
case IM_CREATE_CHAT: case IM_CREATE_CHAT:
{ {
BString user_id = msg->FindString("user_id"); ProtocolLooper* looper = _LooperFromMessage(msg);
if (user_id.IsEmpty() == false) { if (looper != NULL)
User* user = ContactById(user_id, msg->FindInt64("instance")); looper->PostMessage(msg);
user->GetProtocolLooper()->PostMessage(msg);
}
break; break;
} }
case IM_CHAT_CREATED: case IM_CHAT_CREATED:

View File

@ -409,7 +409,6 @@ IrcProtocol::_ProcessCommand(BString command, BString sender,
} }
else if (command == "PRIVMSG") else if (command == "PRIVMSG")
{ {
BString chat_id = params.First(); BString chat_id = params.First();
BString user_id = _SenderIdent(sender); BString user_id = _SenderIdent(sender);
BString body = params.Last(); BString body = params.Last();
@ -429,12 +428,17 @@ IrcProtocol::_ProcessCommand(BString command, BString sender,
BString chat_id = params.First(); BString chat_id = params.First();
BMessage send(IM_MESSAGE); BMessage send(IM_MESSAGE);
send.AddInt32("im_what", IM_MESSAGE_RECEIVED); send.AddInt32("im_what", IM_MESSAGE_RECEIVED);
if (chat_id != "AUTH" && chat_id != "*") {
if (_IsChannelName(chat_id) == false)
chat_id = _SenderNick(sender);
if (chat_id != "AUTH" || chat_id != "*")
send.AddString("chat_id", chat_id); send.AddString("chat_id", chat_id);
sender = "";
if (sender.IsEmpty() == false) {
send.AddString("user_id", _SenderIdent(sender));
send.AddString("user_name", _SenderNick(sender));
} }
if (sender.IsEmpty() == false)
send.AddString("user_id", sender);
send.AddString("body", params.Last()); send.AddString("body", params.Last());
_SendMsg(&send); _SendMsg(&send);
} }
@ -567,8 +571,13 @@ BString
IrcProtocol::_LineSender(BStringList words) IrcProtocol::_LineSender(BStringList words)
{ {
BString sender; BString sender;
if (words.CountStrings() > 1) if (words.CountStrings() > 1) {
sender = words.First().RemoveFirst(":"); sender = words.First();
if (sender.StartsWith(":") == true)
sender.RemoveFirst(":");
else if (sender.StartsWith("*:") == true)
sender.RemoveFirst("*:");
}
return sender; return sender;
} }