This repository has been archived by the owner on Oct 4, 2019. It is now read-only.
forked from steemit/steem
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Not write follow operations dump in wrong cases #1333
- Loading branch information
1 parent
e9a5f5e
commit 2a6002a
Showing
5 changed files
with
72 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <golos/plugins/operation_dump/operation_dump_visitor.hpp> | ||
|
||
namespace golos { namespace plugins { namespace operation_dump { | ||
|
||
template<typename OperationType> | ||
std::vector<OperationType> get_custom_ops(const custom_json_operation& op) { | ||
std::vector<OperationType> ops; | ||
|
||
auto v = fc::json::from_string(op.json); | ||
if (v.is_array() && v.size() > 0 && v.get_array()[0].is_array()) { | ||
fc::from_variant(v, ops); | ||
} else { | ||
ops.emplace_back(); | ||
fc::from_variant(v, ops[0]); | ||
} | ||
|
||
return ops; | ||
} | ||
|
||
std::vector<follow_plugin_operation> get_follow_ops(const custom_json_operation& op, const database& _db) { | ||
std::vector<follow_plugin_operation> fpops; | ||
|
||
if (op.id != "follow") { // follows, reblogs, delete_reblogs | ||
return fpops; | ||
} | ||
|
||
if (!_db.has_index<follow_index>()) { | ||
return fpops; | ||
} | ||
|
||
try { | ||
fpops = get_custom_ops<follow_plugin_operation>(op); | ||
} catch (...) { | ||
// Normal cases failed, try this strange case from follow-plugin | ||
try { | ||
auto fop = fc::json::from_string(op.json).as<follow_operation>(); | ||
fpops.emplace_back(fop); | ||
} catch (...) { | ||
} | ||
} | ||
|
||
return fpops; | ||
} | ||
|
||
} } } // golos::plugins::operation_dump |