MAINT-8203 Group notices processing

Tue, 27 Mar 2018 17:22:17 +0300

author
andreykproductengine <andreykproductengine@lindenlab.com>
date
Tue, 27 Mar 2018 17:22:17 +0300
changeset 55358
5e41325e8fcf
parent 55355
9123341e59d3
child 55359
01236c0008b3

MAINT-8203 Group notices processing

indra/newview/llimprocessing.cpp file | annotate | diff | revisions
indra/newview/llimprocessing.h file | annotate | diff | revisions
     1.1 --- a/indra/newview/llimprocessing.cpp	Sat Mar 24 14:48:39 2018 +0200
     1.2 +++ b/indra/newview/llimprocessing.cpp	Tue Mar 27 17:22:17 2018 +0300
     1.3 @@ -42,6 +42,7 @@
     1.4  #include "llnotificationmanager.h"
     1.5  #include "llpanelgroup.h"
     1.6  #include "llregionhandle.h"
     1.7 +#include "llsdserialize.h"
     1.8  #include "llslurl.h"
     1.9  #include "llstring.h"
    1.10  #include "lltoastnotifypanel.h"
    1.11 @@ -420,7 +421,8 @@
    1.12      LLVector3 position,
    1.13      U8 *binary_bucket,
    1.14      S32 binary_bucket_size,
    1.15 -    LLHost &sender)
    1.16 +    LLHost &sender,
    1.17 +    LLUUID aux_id)
    1.18  {
    1.19      LLChat chat;
    1.20      std::string buffer;
    1.21 @@ -614,54 +616,77 @@
    1.22          case IM_GROUP_NOTICE_REQUESTED:
    1.23          {
    1.24              LL_INFOS("Messaging") << "Received IM_GROUP_NOTICE message." << LL_ENDL;
    1.25 -            // Read the binary bucket for more information.
    1.26 -            struct notice_bucket_header_t
    1.27 +
    1.28 +            LLUUID agent_id = from_id;
    1.29 +            U8 has_inventory;
    1.30 +            U8 asset_type = 0;
    1.31 +            LLUUID group_id;
    1.32 +            std::string item_name;
    1.33 +
    1.34 +            if (aux_id.notNull())
    1.35              {
    1.36 -                U8 has_inventory;
    1.37 -                U8 asset_type;
    1.38 -                LLUUID group_id;
    1.39 -            };
    1.40 -            struct notice_bucket_full_t
    1.41 +                // aux_id contains group id, binary bucket contains name and asset type
    1.42 +                group_id = aux_id;
    1.43 +                has_inventory = binary_bucket_size > 1 ? TRUE : FALSE;
    1.44 +                from_group = TRUE; // inaccurate value correction
    1.45 +                if (has_inventory)
    1.46 +                {
    1.47 +                    std::string str_bucket = ll_safe_string((char*)binary_bucket, binary_bucket_size);
    1.48 +
    1.49 +                    typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
    1.50 +                    boost::char_separator<char> sep("|", "", boost::keep_empty_tokens);
    1.51 +                    tokenizer tokens(str_bucket, sep);
    1.52 +                    tokenizer::iterator iter = tokens.begin();
    1.53 +
    1.54 +                    asset_type = (LLAssetType::EType)(atoi((*(iter++)).c_str()));
    1.55 +                    iter++; // wearable type if applicable, otherwise asset type
    1.56 +                    item_name = std::string((*(iter++)).c_str());
    1.57 +                    // Note There is more elements in 'tokens' ...
    1.58 +
    1.59 +
    1.60 +                    for (int i = 0; i < 6; i++)
    1.61 +                    {
    1.62 +                        LL_WARNS() << *(iter++) << LL_ENDL;
    1.63 +                        iter++;
    1.64 +                    }
    1.65 +                }
    1.66 +            }
    1.67 +            else
    1.68              {
    1.69 -                struct notice_bucket_header_t header;
    1.70 -                U8 item_name[DB_INV_ITEM_NAME_BUF_SIZE];
    1.71 -            }*notice_bin_bucket;
    1.72 +                // All info is in binary bucket, read it for more information.
    1.73 +                struct notice_bucket_header_t
    1.74 +                {
    1.75 +                    U8 has_inventory;
    1.76 +                    U8 asset_type;
    1.77 +                    LLUUID group_id;
    1.78 +                };
    1.79 +                struct notice_bucket_full_t
    1.80 +                {
    1.81 +                    struct notice_bucket_header_t header;
    1.82 +                    U8 item_name[DB_INV_ITEM_NAME_BUF_SIZE];
    1.83 +                }*notice_bin_bucket;
    1.84  
    1.85 -            // Make sure the binary bucket is big enough to hold the header 
    1.86 -            // and a null terminated item name.
    1.87 -            if ((binary_bucket_size < (S32)((sizeof(notice_bucket_header_t) + sizeof(U8))))
    1.88 -                || (binary_bucket[binary_bucket_size - 1] != '\0'))
    1.89 -            {
    1.90 -                LL_WARNS("Messaging") << "Malformed group notice binary bucket" << LL_ENDL;
    1.91 -                break;
    1.92 +                // Make sure the binary bucket is big enough to hold the header 
    1.93 +                // and a null terminated item name.
    1.94 +                if ((binary_bucket_size < (S32)((sizeof(notice_bucket_header_t) + sizeof(U8))))
    1.95 +                    || (binary_bucket[binary_bucket_size - 1] != '\0'))
    1.96 +                {
    1.97 +                    LL_WARNS("Messaging") << "Malformed group notice binary bucket" << LL_ENDL;
    1.98 +                    break;
    1.99 +                }
   1.100 +
   1.101 +                notice_bin_bucket = (struct notice_bucket_full_t*) &binary_bucket[0];
   1.102 +                has_inventory = notice_bin_bucket->header.has_inventory;
   1.103 +                asset_type = notice_bin_bucket->header.asset_type;
   1.104 +                group_id = notice_bin_bucket->header.group_id;
   1.105 +                item_name = ll_safe_string((const char*)notice_bin_bucket->item_name);
   1.106              }
   1.107  
   1.108 -            // The group notice packet does not have an AgentID.  Obtain one from the name cache.
   1.109 -            // If last name is "Resident" strip it out so the cache name lookup works.
   1.110 -            S32 index = original_name.find(" Resident");
   1.111 -            if (index != std::string::npos)
   1.112 -            {
   1.113 -                original_name = original_name.substr(0, index);
   1.114 -            }
   1.115 -
   1.116 -            std::string legacy_name = gCacheName->buildLegacyName(original_name);
   1.117 -            LLUUID agent_id = LLAvatarNameCache::findIdByName(legacy_name);
   1.118 -
   1.119 -            if (agent_id.isNull())
   1.120 -            {
   1.121 -                LL_WARNS("Messaging") << "buildLegacyName returned null while processing " << original_name << LL_ENDL;
   1.122 -            }
   1.123 -            else if (LLMuteList::getInstance()->isMuted(agent_id))
   1.124 +            if (agent_id.notNull() && LLMuteList::getInstance()->isMuted(agent_id))
   1.125              {
   1.126                  break;
   1.127              }
   1.128  
   1.129 -            notice_bin_bucket = (struct notice_bucket_full_t*) &binary_bucket[0];
   1.130 -            U8 has_inventory = notice_bin_bucket->header.has_inventory;
   1.131 -            U8 asset_type = notice_bin_bucket->header.asset_type;
   1.132 -            LLUUID group_id = notice_bin_bucket->header.group_id;
   1.133 -            std::string item_name = ll_safe_string((const char*)notice_bin_bucket->item_name);
   1.134 -
   1.135              // If there is inventory, give the user the inventory offer.
   1.136              LLOfferInfo* info = NULL;
   1.137  
   1.138 @@ -1493,9 +1518,10 @@
   1.139      for (; i != iEnd; ++i)
   1.140      {
   1.141          const LLSD &message_data(*i);
   1.142 +
   1.143          LLVector3 position(message_data["local_x"].asReal(), message_data["local_y"].asReal(), message_data["local_z"].asReal());
   1.144          data = message_data["binary_bucket"].asBinary();
   1.145 -        binary_bucket_size = data.size(); // message_data["count"] == data.size() - 1 due to ('\0')
   1.146 +        binary_bucket_size = data.size(); // message_data["count"] always 0
   1.147          U32 parent_estate_id = message_data.has("parent_estate_id") ? message_data["parent_estate_id"].asInteger() : 1; // 1 - IMMainland
   1.148  
   1.149          // Todo: once dirtsim-369 releases, remove one of the int/str options
   1.150 @@ -1514,7 +1540,7 @@
   1.151              message_data["to_agent_id"].asUUID(),
   1.152              IM_OFFLINE,
   1.153              (EInstantMessage)message_data["dialog"].asInteger(),
   1.154 -            message_data["session_id"].asUUID(),
   1.155 +            LLUUID::null, // session id, fix this for friendship offers to work
   1.156              message_data["timestamp"].asInteger(),
   1.157              message_data["from_agent_name"].asString(),
   1.158              message_data["message"].asString(),
   1.159 @@ -1523,7 +1549,8 @@
   1.160              position,
   1.161              &data[0],
   1.162              binary_bucket_size,
   1.163 -            sender);
   1.164 +            sender,
   1.165 +            message_data["asset_id"].asUUID()); // not necessarily an asset
   1.166      }
   1.167  }
   1.168  
     2.1 --- a/indra/newview/llimprocessing.h	Sat Mar 24 14:48:39 2018 +0200
     2.2 +++ b/indra/newview/llimprocessing.h	Tue Mar 27 17:22:17 2018 +0300
     2.3 @@ -47,7 +47,8 @@
     2.4          LLVector3 position,
     2.5          U8 *binary_bucket,
     2.6          S32 binary_bucket_size,
     2.7 -        LLHost &sender);
     2.8 +        LLHost &sender,
     2.9 +        LLUUID aux_id = LLUUID::null);
    2.10  
    2.11      // Either receives list of offline messages from 'ReadOfflineMsgs' capability
    2.12      // or uses legacy method

mercurial