2018-04-28 22:22:28 +02:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
|
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/actor/PromiseFuture.h"
|
|
|
|
|
|
|
|
#include "td/db/binlog/BinlogHelper.h"
|
|
|
|
|
|
|
|
#include "td/telegram/Global.h"
|
|
|
|
#include "td/telegram/TdDb.h"
|
|
|
|
|
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2018-05-09 19:14:17 +02:00
|
|
|
inline Promise<Unit> get_erase_logevent_promise(uint64 logevent_id, Promise<Unit> promise = Promise<Unit>()) {
|
2018-04-28 22:22:28 +02:00
|
|
|
if (logevent_id == 0) {
|
2018-05-07 19:20:20 +02:00
|
|
|
return promise;
|
2018-04-28 22:22:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return PromiseCreator::lambda([logevent_id, promise = std::move(promise)](Result<Unit> result) mutable {
|
|
|
|
if (!G()->close_flag()) {
|
2018-06-28 15:52:40 +02:00
|
|
|
binlog_erase(G()->td_db()->get_binlog(), logevent_id);
|
2018-04-28 22:22:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
promise.set_result(std::move(result));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|