mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add support for gravatar urls to AccountState.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "../json/writer.h"
|
||||
|
||||
@@ -27,16 +28,31 @@ AccountState::AccountState(SerializedLedgerEntry::pointer ledgerEntry) : mLedger
|
||||
mValid = true;
|
||||
}
|
||||
|
||||
std::string AccountState::createGravatarUrl(uint128 uEmailHash)
|
||||
{
|
||||
std::vector<unsigned char> vucMD5(uEmailHash.begin(), uEmailHash.end());
|
||||
std::string strMD5Lower = strHex(vucMD5);
|
||||
boost::to_lower(strMD5Lower);
|
||||
|
||||
return str(boost::format("http://www.gravatar.com/avatar/%s") % strMD5Lower);
|
||||
}
|
||||
|
||||
void AccountState::addJson(Json::Value& val)
|
||||
{
|
||||
val = mLedgerEntry->getJson(0);
|
||||
|
||||
if (!mValid) val["Invalid"] = true;
|
||||
|
||||
if (mLedgerEntry->getIFieldPresent(sfEmailHash))
|
||||
val["UrlGravatar"] = createGravatarUrl(mLedgerEntry->getIFieldH128(sfEmailHash));
|
||||
}
|
||||
|
||||
void AccountState::dump()
|
||||
{
|
||||
Json::Value j(Json::objectValue);
|
||||
|
||||
addJson(j);
|
||||
|
||||
Json::StyledStreamWriter ssw;
|
||||
ssw.write(std::cerr, j);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
std::vector<unsigned char> getRaw() const;
|
||||
void addJson(Json::Value& value);
|
||||
void dump();
|
||||
|
||||
static std::string createGravatarUrl(uint128 uEmailHash);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user