Repository navigation
Expand file tree
/
Copy pathforum.cpp
More file actions
38 lines (31 loc) · 1.62 KB
/
Copy pathforum.cpp
File metadata and controls
38 lines (31 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <eosiolib/eosio.hpp>
#include <string>
using eosio::name;
class forum : public eosio::contract {
public:
forum(account_name self)
:eosio::contract(self)
{}
/// @param certify - under penalty of perjury the content of this post is true.
// @abi
void post(const account_name account, const uint32_t post_num, const std::string& title, const std::string& content,
const account_name reply_to_account, const uint32_t reply_to_post_num, const bool certify) {
require_auth(account);
eosio_assert(title.size() < 128, "Title should be less than 128 characters long.");
eosio_assert(content.size() > 0, "Content should be more than 0 characters long.");
eosio_assert(content.size() < 1024 * 1024 * 10, "Content should be less than 10 KB long.");
eosio_assert(post_num > 0, "Post number should be greater than 0 to post.");
if (reply_to_account == 0) {
eosio_assert(reply_to_post_num == 0, "If reply_to_account is not set, reply_to_post_num should not be set.");
} else {
eosio_assert(is_account(reply_to_account), "reply_to_account must be a valid account.");
eosio_assert(title.size() == 0, "If the post is a reply, there should not be a title.");
}
};
// @abi
void remove(const account_name account, const uint32_t post_num) {
require_auth(account);
eosio_assert(post_num > 0, "Post number should be greater than 0 to remove.");
}
};
EOSIO_ABI( forum, (post)(remove) )