forked from mtusi2026/mtusi2026lab5
29 lines
773 B
C++
29 lines
773 B
C++
#pragma once
|
|
|
|
#include "db.hpp"
|
|
#include "models.hpp"
|
|
|
|
#include <optional>
|
|
#include <functional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class AttachmentRepo {
|
|
public:
|
|
explicit AttachmentRepo(PgPool& pool) : pool_(pool) {}
|
|
|
|
Attachment insert(const Attachment& a);
|
|
Attachment insert_queued(const Attachment& a, const std::string& job_id,
|
|
const std::function<void()>& save_original);
|
|
|
|
std::optional<Attachment> find_by_id(const std::string& id);
|
|
|
|
// All IDs must exist, belong to chat_id, and not have status=failed.
|
|
// Returns false if any id is missing/foreign/failed.
|
|
bool all_belong_to_chat(const std::string& chat_id,
|
|
const std::vector<std::string>& ids);
|
|
|
|
private:
|
|
PgPool& pool_;
|
|
};
|