- res = append(res,
- *NewTransaction(
- tranInviteToChat,
- &targetID,
- NewField(fieldChatID, newChatID),
- NewField(fieldUserName, cc.UserName),
- NewField(fieldUserID, *cc.ID),
- ),
- )
+ // Check if target user has "Refuse private chat" flag
+ binary.BigEndian.Uint16(targetID)
+ targetClient := cc.Server.Clients[binary.BigEndian.Uint16(targetID)]
+
+ flagBitmap := big.NewInt(int64(binary.BigEndian.Uint16(targetClient.Flags)))
+ if flagBitmap.Bit(userFLagRefusePChat) == 1 {
+ res = append(res,
+ *NewTransaction(
+ TranServerMsg,
+ cc.ID,
+ NewField(FieldData, []byte(string(targetClient.UserName)+" does not accept private chats.")),
+ NewField(FieldUserName, targetClient.UserName),
+ NewField(FieldUserID, *targetClient.ID),
+ NewField(FieldOptions, []byte{0, 2}),
+ ),
+ )
+ } else {
+ res = append(res,
+ *NewTransaction(
+ TranInviteToChat,
+ &targetID,
+ NewField(FieldChatID, newChatID),
+ NewField(FieldUserName, cc.UserName),
+ NewField(FieldUserID, *cc.ID),
+ ),
+ )
+ }