Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Commit f1122e7

Browse files
authored
Merge pull request #935 from GolosChain/golos-v0.18.4
Golos v0.18.4
2 parents f8a38d8 + 9524c4d commit f1122e7

25 files changed

Lines changed: 285 additions & 57 deletions

File tree

libraries/api/account_api_object.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ account_api_object::account_api_object(const account_object& a, const golos::cha
7070
}
7171
}
7272

73-
account_api_object::account_api_object() {}
73+
account_api_object::account_api_object() = default;
7474

7575
} } // golos::api

libraries/api/include/golos/api/account_api_object.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ using protocol::public_key_type;
1818

1919
struct account_api_object {
2020
account_api_object(const account_object&, const golos::chain::database&);
21+
2122
account_api_object();
2223

2324
account_object::id_type id;

libraries/api/include/golos/api/discussion.hpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <golos/api/vote_state.hpp>
44
#include <golos/api/comment_api_object.hpp>
5+
#include <golos/api/reblog_entry.hpp>
56

67

78
namespace golos { namespace api {
@@ -12,8 +13,7 @@ namespace golos { namespace api {
1213

1314
}
1415

15-
discussion() {
16-
}
16+
discussion() = default;
1717

1818
string url; /// /category/@rootauthor/root_permlink#author/permlink
1919

@@ -36,9 +36,15 @@ namespace golos { namespace api {
3636
double hot = 0;
3737
double trending = 0;
3838
uint32_t body_length = 0;
39+
3940
std::vector<account_name_type> reblogged_by;
40-
optional <account_name_type> first_reblogged_by;
41-
optional <time_point_sec> first_reblogged_on;
41+
optional<account_name_type> first_reblogged_by;
42+
optional<time_point_sec> first_reblogged_on;
43+
optional<account_name_type> reblog_author;
44+
optional<std::string> reblog_title;
45+
optional<std::string> reblog_body;
46+
optional<std::string> reblog_json_metadata;
47+
std::vector<reblog_entry> reblog_entries;
4248
};
4349

4450
} } // golos::api
@@ -49,4 +55,5 @@ FC_REFLECT_DERIVED( (golos::api::discussion), ((golos::api::comment_api_object))
4955
(pending_benefactor_payout_value)(pending_benefactor_payout_gests_value)
5056
(pending_curator_payout_value)(pending_curator_payout_gests_value)
5157
(pending_payout_value)(total_pending_payout_value)(active_votes)(active_votes_count)(replies)
52-
(author_reputation)(promoted)(body_length)(reblogged_by)(first_reblogged_by)(first_reblogged_on))
58+
(author_reputation)(promoted)(body_length)(reblogged_by)(first_reblogged_by)(first_reblogged_on)
59+
(reblog_author)(reblog_title)(reblog_body)(reblog_json_metadata)(reblog_entries))
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
3+
#include <golos/chain/database.hpp>
4+
5+
namespace golos { namespace api {
6+
7+
struct reblog_entry {
8+
account_name_type author;
9+
std::string title;
10+
std::string body;
11+
std::string json_metadata;
12+
13+
reblog_entry() = default;
14+
15+
reblog_entry(const account_name_type& author_, const std::string& title_, const std::string& body_,
16+
const std::string& json_metadata_)
17+
: author(author_), title(title_), body(body_), json_metadata(json_metadata_) {
18+
}
19+
};
20+
21+
} } // golos::api
22+
23+
FC_REFLECT((golos::api::reblog_entry), (author)(title)(body)(json_metadata));

plugins/follow/follow_evaluators.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace golos {
88
namespace plugins {
99
namespace follow {
10+
using golos::chain::from_string;
1011

1112
void save_blog_stats(database& db, account_name_type blogger, account_name_type guest, uint32_t start_count = 0) {
1213

@@ -154,6 +155,9 @@ namespace golos {
154155
b.comment = c.id;
155156
b.reblogged_on = db().head_block_time();
156157
b.blog_feed_id = next_blog_id;
158+
from_string(b.reblog_title, o.title);
159+
from_string(b.reblog_body, o.body);
160+
from_string(b.reblog_json_metadata, o.json_metadata);
157161
});
158162

159163
save_blog_stats(db(), o.account, c.author, 1);

plugins/follow/follow_operations.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,26 @@ namespace golos {
2323
GOLOS_CHECK_LOGIC(account != author,
2424
logic_errors::cannot_reblog_own_content,
2525
"You cannot reblog your own content");
26+
2627
GOLOS_CHECK_PARAM(permlink, validate_permlink(permlink));
28+
29+
if (title.size() > 0 || body.size() > 0 || json_metadata.size() > 0) {
30+
GOLOS_CHECK_PARAM(title, {
31+
GOLOS_CHECK_VALUE(title.size() < 256, "Title larger than size limit");
32+
GOLOS_CHECK_VALUE(fc::is_utf8(title), "Title not formatted in UTF8");
33+
});
34+
35+
GOLOS_CHECK_PARAM(body, {
36+
GOLOS_CHECK_VALUE(body.size() > 0, "Body is empty but Title or JSON Metadata is set");
37+
GOLOS_CHECK_VALUE(fc::is_utf8(body), "Body not formatted in UTF8");
38+
});
39+
40+
if (json_metadata.size() > 0) {
41+
GOLOS_CHECK_PARAM(json_metadata, {
42+
GOLOS_CHECK_VALUE(fc::json::is_valid(json_metadata), "JSON Metadata not valid JSON");
43+
});
44+
}
45+
}
2746
}
2847

2948
void delete_reblog_operation::validate() const {

plugins/follow/include/golos/plugins/follow/follow_api_object.hpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,29 @@
22
#define GOLOS_FOLLOW_API_OBJECT_HPP
33

44
#include <golos/api/comment_api_object.hpp>
5+
#include <golos/api/reblog_entry.hpp>
56
#include <golos/plugins/follow/follow_objects.hpp>
67
#include "follow_forward.hpp"
78

89
namespace golos {
910
namespace plugins {
1011
namespace follow {
1112
using golos::api::comment_api_object;
13+
using golos::api::reblog_entry;
1214

1315
struct feed_entry {
1416
std::string author;
1517
std::string permlink;
1618
std::vector<std::string> reblog_by;
19+
std::vector<reblog_entry> reblog_entries;
1720
time_point_sec reblog_on;
1821
uint32_t entry_id = 0;
1922
};
2023

2124
struct comment_feed_entry {
2225
comment_api_object comment;
2326
std::vector<std::string> reblog_by;
27+
std::vector<reblog_entry> reblog_entries;
2428
time_point_sec reblog_on;
2529
uint32_t entry_id = 0;
2630
};
@@ -31,13 +35,19 @@ namespace golos {
3135
std::string blog;
3236
time_point_sec reblog_on;
3337
uint32_t entry_id = 0;
38+
std::string reblog_title;
39+
std::string reblog_body;
40+
std::string reblog_json_metadata;
3441
};
3542

3643
struct comment_blog_entry {
3744
comment_api_object comment;
3845
std::string blog;
3946
time_point_sec reblog_on;
4047
uint32_t entry_id = 0;
48+
std::string reblog_title;
49+
std::string reblog_body;
50+
std::string reblog_json_metadata;
4151
};
4252

4353
struct account_reputation {
@@ -55,8 +65,10 @@ namespace golos {
5565
std::string author;
5666
uint32_t count;
5767
};
68+
5869
struct follow_count_api_obj {
59-
follow_count_api_obj() {}
70+
follow_count_api_obj() = default;
71+
6072
follow_count_api_obj(const std::string& acc,
6173
uint32_t followers,
6274
uint32_t followings,
@@ -82,13 +94,15 @@ namespace golos {
8294
using blog_authors_r = std::vector<std::pair<std::string, uint32_t>>;
8395
}}}
8496

85-
FC_REFLECT((golos::plugins::follow::feed_entry), (author)(permlink)(reblog_by)(reblog_on)(entry_id));
97+
FC_REFLECT((golos::plugins::follow::feed_entry), (author)(permlink)(reblog_by)(reblog_entries)(reblog_on)(entry_id));
8698

87-
FC_REFLECT((golos::plugins::follow::comment_feed_entry), (comment)(reblog_by)(reblog_on)(entry_id));
99+
FC_REFLECT((golos::plugins::follow::comment_feed_entry), (comment)(reblog_by)(reblog_entries)(reblog_on)(entry_id));
88100

89-
FC_REFLECT((golos::plugins::follow::blog_entry), (author)(permlink)(blog)(reblog_on)(entry_id));
101+
FC_REFLECT((golos::plugins::follow::blog_entry), (author)(permlink)(blog)(reblog_on)(entry_id)
102+
(reblog_title)(reblog_body)(reblog_json_metadata));
90103

91-
FC_REFLECT((golos::plugins::follow::comment_blog_entry), (comment)(blog)(reblog_on)(entry_id));
104+
FC_REFLECT((golos::plugins::follow::comment_blog_entry), (comment)(blog)(reblog_on)(entry_id)
105+
(reblog_title)(reblog_body)(reblog_json_metadata));
92106

93107
FC_REFLECT((golos::plugins::follow::account_reputation), (account)(reputation));
94108

plugins/follow/include/golos/plugins/follow/follow_objects.hpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace golos {
1616
using golos::chain::by_id;
1717
using golos::chain::comment_vote_index;
1818
using golos::chain::by_comment_voter;
19+
using golos::chain::shared_string;
1920

2021
#ifndef FOLLOW_SPACE_ID
2122
#define FOLLOW_SPACE_ID 8
@@ -38,9 +39,6 @@ namespace golos {
3839
c(*this);
3940
}
4041

41-
follow_object() {
42-
}
43-
4442
id_type id;
4543

4644
account_name_type follower;
@@ -73,23 +71,26 @@ namespace golos {
7371

7472
typedef object_id<feed_object> feed_id_type;
7573

76-
7774
class blog_object : public object<blog_object_type, blog_object> {
7875
public:
76+
blog_object() = delete;
77+
7978
template<typename Constructor, typename Allocator>
80-
blog_object(Constructor &&c, allocator<Allocator> a) {
79+
blog_object(Constructor &&c, allocator<Allocator> a)
80+
: reblog_title(a), reblog_body(a), reblog_json_metadata(a) {
8181
c(*this);
8282
}
8383

84-
blog_object() {
85-
}
86-
8784
id_type id;
8885

8986
account_name_type account;
9087
comment_object::id_type comment;
9188
time_point_sec reblogged_on;
9289
uint32_t blog_feed_id = 0;
90+
91+
shared_string reblog_title;
92+
shared_string reblog_body;
93+
shared_string reblog_json_metadata;
9394
};
9495

9596
typedef object_id<blog_object> blog_id_type;
@@ -125,9 +126,6 @@ namespace golos {
125126
c(*this);
126127
}
127128

128-
reputation_object() {
129-
}
130-
131129
id_type id;
132130

133131
account_name_type account;
@@ -144,9 +142,6 @@ namespace golos {
144142
c(*this);
145143
}
146144

147-
follow_count_object() {
148-
}
149-
150145
id_type id;
151146

152147
account_name_type account;

plugins/follow/include/golos/plugins/follow/follow_operations.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ namespace golos {
2424
protocol::account_name_type account;
2525
protocol::account_name_type author;
2626
std::string permlink;
27+
string title;
28+
string body;
29+
string json_metadata;
2730

2831
void validate() const;
2932
void get_required_posting_authorities(flat_set<account_name_type>& a) const {
@@ -49,7 +52,7 @@ namespace golos {
4952
} // golos::follow
5053

5154
FC_REFLECT((golos::plugins::follow::follow_operation), (follower)(following)(what));
52-
FC_REFLECT((golos::plugins::follow::reblog_operation), (account)(author)(permlink));
55+
FC_REFLECT((golos::plugins::follow::reblog_operation), (account)(author)(permlink)(title)(body)(json_metadata));
5356
FC_REFLECT((golos::plugins::follow::delete_reblog_operation), (account)(author)(permlink));
5457

5558
FC_REFLECT_TYPENAME((golos::plugins::follow::follow_plugin_operation));

plugins/follow/plugin.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,10 +542,18 @@ namespace golos {
542542
entry.entry_id = itr->account_feed_id;
543543
if (itr->first_reblogged_by != account_name_type()) {
544544
entry.reblog_by.reserve(itr->reblogged_by.size());
545+
entry.reblog_entries.reserve(itr->reblogged_by.size());
545546
for (const auto& a : itr->reblogged_by) {
546547
entry.reblog_by.push_back(a);
548+
const auto& blog_idx = db.get_index<blog_index>().indices().get<by_comment>();
549+
auto blog_itr = blog_idx.find(std::make_tuple(itr->comment, a));
550+
entry.reblog_entries.emplace_back(
551+
a,
552+
to_string(blog_itr->reblog_title),
553+
to_string(blog_itr->reblog_body),
554+
to_string(blog_itr->reblog_json_metadata)
555+
);
547556
}
548-
//entry.reblog_by = itr->first_reblogged_by;
549557
entry.reblog_on = itr->first_reblogged_on;
550558
}
551559
result.push_back(entry);
@@ -579,10 +587,18 @@ namespace golos {
579587
entry.comment = helper->create_comment_api_object(comment);
580588
entry.entry_id = itr->account_feed_id;
581589
if (itr->first_reblogged_by != account_name_type()) {
582-
//entry.reblog_by = itr->first_reblogged_by;
583590
entry.reblog_by.reserve(itr->reblogged_by.size());
591+
entry.reblog_entries.reserve(itr->reblogged_by.size());
584592
for (const auto& a : itr->reblogged_by) {
585593
entry.reblog_by.push_back(a);
594+
const auto& blog_idx = db.get_index<blog_index>().indices().get<by_comment>();
595+
auto blog_itr = blog_idx.find(std::make_tuple(itr->comment, a));
596+
entry.reblog_entries.emplace_back(
597+
a,
598+
to_string(blog_itr->reblog_title),
599+
to_string(blog_itr->reblog_body),
600+
to_string(blog_itr->reblog_json_metadata)
601+
);
586602
}
587603
entry.reblog_on = itr->first_reblogged_on;
588604
}
@@ -619,6 +635,9 @@ namespace golos {
619635
entry.blog = account;
620636
entry.reblog_on = itr->reblogged_on;
621637
entry.entry_id = itr->blog_feed_id;
638+
entry.reblog_title = to_string(itr->reblog_title);
639+
entry.reblog_body = to_string(itr->reblog_body);
640+
entry.reblog_json_metadata = to_string(itr->reblog_json_metadata);
622641

623642
result.push_back(entry);
624643

@@ -652,6 +671,9 @@ namespace golos {
652671
entry.blog = account;
653672
entry.reblog_on = itr->reblogged_on;
654673
entry.entry_id = itr->blog_feed_id;
674+
entry.reblog_title = to_string(itr->reblog_title);
675+
entry.reblog_body = to_string(itr->reblog_body);
676+
entry.reblog_json_metadata = to_string(itr->reblog_json_metadata);
655677

656678
result.push_back(entry);
657679

0 commit comments

Comments
 (0)