e034b46
use db::repo::repos;
use gitsync::{PostReceiveRefUpdate, PostReceiveTask};
use serde_json::json;
#[must_use]
pub fn build_push_payload(
task: &PostReceiveTask,
repo: &repos::Model,
update: &PostReceiveRefUpdate,
) -> serde_json::Value {
let pusher_id = task.actor_id.map_or_else(String::new, |id| id.to_string());
json!({
"ref": update.name,
"before": update.old_oid,
"after": update.new_oid,
"created": update.is_create(),
"deleted": update.is_delete(),
"pusher": { "id": pusher_id },
"sender": { "id": pusher_id },
"repository": {
"id": repo.id.to_string(),
"name": repo.name,
"full_name": format!("{}/{}", repo.channel_id, repo.name),
"default_branch": repo.default_branch,
"channel_id": repo.channel_id.to_string(),
},
})
}