move AbstractPost definition to a separate header; add post source tracking
This commit is contained in:
parent
182ddffe41
commit
aaef54f72e
@ -7,7 +7,7 @@ add_subdirectory(libuv)
|
||||
add_subdirectory(spdlog)
|
||||
add_subdirectory(td)
|
||||
|
||||
add_executable(${PROJECT_NAME} main.cpp config.cpp http.cpp manager.cpp state.cpp tg.cpp vk.cpp)
|
||||
add_executable(${PROJECT_NAME} main.cpp config.cpp http.cpp manager.cpp posts.cpp state.cpp tg.cpp vk.cpp)
|
||||
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -std=c++2b)
|
||||
|
||||
|
@ -281,7 +281,7 @@ std::vector<AbstractPost> RepostManager::to_abstract_posts(std::vector<vk::Post>
|
||||
std::vector<AbstractPost> result;
|
||||
result.reserve(posts.size());
|
||||
for (auto &post : posts) {
|
||||
result.emplace_back(post.id, post.date, post.text);
|
||||
result.emplace_back(posts::SRC_VK, post.id, post.date, post.text);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -293,7 +293,7 @@ std::vector<AbstractPost> RepostManager::to_abstract_posts(std::vector<td::tl::u
|
||||
// we don't want any posts other than plain text (yet)
|
||||
if (post->content_->get_id() == td_api::messageText::ID) {
|
||||
auto &content = (td_api::messageText&) *post->content_;
|
||||
result.emplace_back(post->id_, post->date_, content.text_->text_);
|
||||
result.emplace_back(posts::SRC_TELEGRAM, post->id_, post->date_, content.text_->text_);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1,22 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#include "posts.h"
|
||||
#include "state.h"
|
||||
#include "tg.h"
|
||||
#include "vk.h"
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace manager {
|
||||
namespace td_api = td::td_api;
|
||||
|
||||
struct AbstractPost {
|
||||
inline AbstractPost(long id, long date, std::string text) : id(id), date(date), text(text) {}
|
||||
long id;
|
||||
long date;
|
||||
std::string text;
|
||||
};
|
||||
using posts::AbstractPost;
|
||||
|
||||
class RepostManager {
|
||||
public:
|
||||
|
17
posts.h
Normal file
17
posts.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace posts {
|
||||
enum PostSource {
|
||||
SRC_VK, SRC_TELEGRAM
|
||||
};
|
||||
|
||||
struct AbstractPost {
|
||||
inline AbstractPost(PostSource src, long id, long date, std::string text) : source(src), id(id), date(date), text(text) {}
|
||||
long id;
|
||||
long date;
|
||||
std::string text;
|
||||
PostSource source;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user