0f2769bc77
GitOrigin-RevId: 8e92413b65a9fdf9848680f4b65568752ea22365
35 lines
908 B
C++
35 lines
908 B
C++
//
|
|
// 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 {
|
|
|
|
Promise<Unit> get_erase_logevent_promise(uint64 logevent_id, Promise<Unit> promise = Promise<Unit>()) {
|
|
if (logevent_id == 0) {
|
|
return std::move(promise);
|
|
}
|
|
|
|
return PromiseCreator::lambda([logevent_id, promise = std::move(promise)](Result<Unit> result) mutable {
|
|
if (!G()->close_flag()) {
|
|
BinlogHelper::erase(G()->td_db()->get_binlog(), logevent_id);
|
|
}
|
|
|
|
promise.set_result(std::move(result));
|
|
});
|
|
}
|
|
|
|
} // namespace td
|