X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/edcafb1c0673218fb7c17d96c81bb9db4f806e58..f56220e9c360d83ecc670560b012bbdec08c1a0f:/hotline/transaction_handlers.go diff --git a/hotline/transaction_handlers.go b/hotline/transaction_handlers.go index 2dc5e06..abe2ea8 100644 --- a/hotline/transaction_handlers.go +++ b/hotline/transaction_handlers.go @@ -321,14 +321,29 @@ func HandleSendInstantMsg(cc *ClientConn, t *Transaction) (res []Transaction, er reply.Fields = append(reply.Fields, NewField(fieldQuotingMsg, t.GetField(fieldQuotingMsg).Data)) } - res = append(res, *reply) - id, _ := byteToInt(ID.Data) otherClient, ok := cc.Server.Clients[uint16(id)] if !ok { return res, errors.New("invalid client ID") } + // Check if target user has "Refuse private messages" flag + flagBitmap := big.NewInt(int64(binary.BigEndian.Uint16(otherClient.Flags))) + if flagBitmap.Bit(userFLagRefusePChat) == 1 { + res = append(res, + *NewTransaction( + tranServerMsg, + cc.ID, + NewField(fieldData, []byte(string(otherClient.UserName)+" does not accept private messages.")), + NewField(fieldUserName, otherClient.UserName), + NewField(fieldUserID, *otherClient.ID), + NewField(fieldOptions, []byte{0, 2}), + ), + ) + } else { + res = append(res, *reply) + } + // Respond with auto reply if other client has it enabled if len(otherClient.AutoReply) > 0 { res = append(res, @@ -1704,8 +1719,6 @@ func HandleInviteNewChat(cc *ClientConn, t *Transaction) (res []Transaction, err targetID := t.GetField(fieldUserID).Data newChatID := cc.Server.NewPrivateChat(cc) - // Halcyon does not accept private chats. - // Check if target user has "Refuse private chat" flag binary.BigEndian.Uint16(targetID) targetClient := cc.Server.Clients[binary.BigEndian.Uint16(targetID)] @@ -1716,7 +1729,7 @@ func HandleInviteNewChat(cc *ClientConn, t *Transaction) (res []Transaction, err *NewTransaction( tranServerMsg, cc.ID, - NewField(fieldData, []byte(string(targetClient.UserName)+" does not accept private messages.")), + NewField(fieldData, []byte(string(targetClient.UserName)+" does not accept private chats.")), NewField(fieldUserName, targetClient.UserName), NewField(fieldUserID, *targetClient.ID), NewField(fieldOptions, []byte{0, 2}),