mirror of
https://github.com/matrix-construct/construct
synced 2024-05-28 15:53:46 +02:00
modules/web_hook: Aggregate status updates on cancel to reduce edit load.
This commit is contained in:
parent
715f21564e
commit
c8ff5bbc37
|
@ -1174,11 +1174,35 @@ github_handle__workflow_job(std::ostream &out,
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const fmt::bsprintf<512> expect_unmodified
|
||||||
|
{
|
||||||
|
"%s%s</a>",
|
||||||
|
string_view{expect},
|
||||||
|
annote(workflow_job),
|
||||||
|
};
|
||||||
|
|
||||||
|
bool modified
|
||||||
|
{
|
||||||
|
!tokens(td, ""_sv, [&]
|
||||||
|
(const string_view &cell)
|
||||||
|
{
|
||||||
|
if(!startswith(cell, expect))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return cell == expect_unmodified; // return false for found
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
const bool cancelled
|
||||||
|
{
|
||||||
|
json::string(workflow_job["conclusion"]) == "cancelled"
|
||||||
|
};
|
||||||
|
|
||||||
string_view tab;
|
string_view tab;
|
||||||
tab = ircd::strlcpy(buf, view(heading, headbuf));
|
tab = ircd::strlcpy(buf, view(heading, headbuf));
|
||||||
tab = ircd::strlcat(buf, "<table><tr><td>");
|
tab = ircd::strlcat(buf, "<table><tr><td>");
|
||||||
|
|
||||||
if(exists)
|
if(exists && modified && !cancelled)
|
||||||
tokens(td, ""_sv, [&]
|
tokens(td, ""_sv, [&]
|
||||||
(const string_view &cell)
|
(const string_view &cell)
|
||||||
{
|
{
|
||||||
|
@ -1196,7 +1220,8 @@ github_handle__workflow_job(std::ostream &out,
|
||||||
tab = ircd::strlcat(buf, "</a>");
|
tab = ircd::strlcat(buf, "</a>");
|
||||||
tab = ircd::strlcat(buf, ""_sv);
|
tab = ircd::strlcat(buf, ""_sv);
|
||||||
});
|
});
|
||||||
else
|
|
||||||
|
if(!exists || (modified && cancelled))
|
||||||
github_run_for_each_jobs(github_repopath(content), run_id, [&]
|
github_run_for_each_jobs(github_repopath(content), run_id, [&]
|
||||||
(const json::object &workflow_job)
|
(const json::object &workflow_job)
|
||||||
{
|
{
|
||||||
|
@ -1209,30 +1234,34 @@ github_handle__workflow_job(std::ostream &out,
|
||||||
tab = ircd::strlcat(buf, annote(workflow_job));
|
tab = ircd::strlcat(buf, annote(workflow_job));
|
||||||
tab = ircd::strlcat(buf, "</a>");
|
tab = ircd::strlcat(buf, "</a>");
|
||||||
tab = ircd::strlcat(buf, ""_sv);
|
tab = ircd::strlcat(buf, ""_sv);
|
||||||
|
modified = true;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
tab = ircd::strlcat(buf, "</td></tr></table>");
|
if(modified)
|
||||||
|
|
||||||
m::message(_webhook_room, _webhook_user, json::members
|
|
||||||
{
|
{
|
||||||
{ "body", alt_up },
|
tab = ircd::strlcat(buf, "</td></tr></table>");
|
||||||
{ "msgtype", "m.notice" },
|
|
||||||
{ "format", "org.matrix.custom.html" },
|
m::message(_webhook_room, _webhook_user, json::members
|
||||||
{ "formatted_body", tab },
|
|
||||||
{ "m.new_content", json::members
|
|
||||||
{
|
{
|
||||||
{ "body", alt_up },
|
{ "body", alt_up },
|
||||||
{ "msgtype", "m.notice" },
|
{ "msgtype", "m.notice" },
|
||||||
{ "format", "org.matrix.custom.html" },
|
{ "format", "org.matrix.custom.html" },
|
||||||
{ "formatted_body", tab },
|
{ "formatted_body", tab },
|
||||||
}},
|
{ "m.new_content", json::members
|
||||||
{ "m.relates_to", json::members
|
{
|
||||||
{
|
{ "body", alt_up },
|
||||||
{ "event_id", orig_table_id },
|
{ "msgtype", "m.notice" },
|
||||||
{ "rel_type", "m.replace" },
|
{ "format", "org.matrix.custom.html" },
|
||||||
}}
|
{ "formatted_body", tab },
|
||||||
});
|
}},
|
||||||
|
{ "m.relates_to", json::members
|
||||||
|
{
|
||||||
|
{ "event_id", orig_table_id },
|
||||||
|
{ "rel_type", "m.replace" },
|
||||||
|
}}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(json::string(workflow_job["conclusion"]) != "skipped")
|
else if(json::string(workflow_job["conclusion"]) != "skipped")
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue