Preserve channel reply context through attachment preparation
This commit is contained in:
1 parent
68037b25a5
commit
e811ac395a
2 files changed
+5
No files matched your search
@@ -66,6 +66,7 @@ static void attachment_publish(struct attachment_send_req* req, int error) {
|
||||
if (error || req->error || attachment_validate(&req->info)) {
|
||||
chat_event_attachment(req->inst, req->is_dm, req->target, req->id, 2);
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "attachment: preparation failed target=%s error=%d worker=%d", req->target, error, req->error);
|
||||
chat_event_submitted(req->inst, req->request_id, 0);
|
||||
if (remove(req->output) && errno != ENOENT) DEBUG_WARN(DEBUG_CATEGORY_MEDIA, "attachment: output cleanup failed path=%s", req->output);
|
||||
u_free(req); return;
|
||||
}
|
||||
@@ -92,6 +93,7 @@ static void attachment_publish(struct attachment_send_req* req, int error) {
|
||||
struct chat_msg_submit* message = u_calloc(1, sizeof(*message) + length);
|
||||
if (message) {
|
||||
message->inst = req->inst;
|
||||
memcpy(message->reply_to, req->reply_to, 32); message->request_id = req->request_id;
|
||||
snprintf(message->channel_id, sizeof(message->channel_id), "%s", req->target);
|
||||
snprintf(message->content_type, sizeof(message->content_type), "%s", attachment_content_type(req->info.kind));
|
||||
snprintf(message->media_src, sizeof(message->media_src), "%s", req->output);
|
||||
@@ -101,6 +103,7 @@ static void attachment_publish(struct attachment_send_req* req, int error) {
|
||||
chat_core_submit_trampoline(message);
|
||||
} else {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "attachment: channel dispatch allocation failed");
|
||||
chat_event_submitted(req->inst, req->request_id, 0);
|
||||
chat_event_attachment(req->inst, req->is_dm, req->target, req->id, 2);
|
||||
if (remove(req->output)) DEBUG_WARN(DEBUG_CATEGORY_MEDIA, "attachment: rejected output cleanup failed");
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ struct attachment_send_req {
|
||||
struct UTUN_INSTANCE* inst;
|
||||
char target[64]; /* Десятичный channel_id либо conv_id без префикса dm:, зафиксированный до подготовки. */
|
||||
int is_dm;
|
||||
uint8_t reply_to[32]; /* Оригинал канального ответа, зафиксированный до подготовки. */
|
||||
uint64_t request_id; /* CHAT_EVT_MSG_SUBMITTED после публикации либо ошибки. */
|
||||
struct attachment_info info;
|
||||
uint8_t id[16];
|
||||
char source[1024], output[1024];
|
||||
|
||||
Reference in new issue
Block a user