Rename webhook to hook where appropriate
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
1301275788
commit
1cf93d1ba8
4 changed files with 16 additions and 16 deletions
10
src/bot.rs
10
src/bot.rs
|
@ -13,7 +13,7 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::webhook::{format_webhook, GitlabHook};
|
||||
use crate::hook::{format_hook, GitlabHook};
|
||||
|
||||
use log::debug;
|
||||
use xmpp::parsers::message::MessageType;
|
||||
|
@ -74,10 +74,10 @@ impl XmppClient {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn webhook(&mut self, wh: GitlabHook) {
|
||||
debug!("Received Webhook");
|
||||
if let Some(display) = format_webhook(&wh) {
|
||||
debug!("Webhook: {}", display);
|
||||
pub async fn hook(&mut self, wh: GitlabHook) {
|
||||
debug!("Received Hook");
|
||||
if let Some(display) = format_hook(&wh) {
|
||||
debug!("Hook: {}", display);
|
||||
for room in &self.rooms {
|
||||
self.agent
|
||||
.send_message(
|
||||
|
|
|
@ -31,7 +31,7 @@ impl From<GitlabHook> for Hook {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn format_webhook(glh: &GitlabHook) -> Option<String> {
|
||||
pub fn format_hook(glh: &GitlabHook) -> Option<String> {
|
||||
Some(match glh {
|
||||
GitlabHook::Push(push) => {
|
||||
if push.ref_ != "refs/heads/main" {
|
||||
|
@ -154,7 +154,7 @@ pub fn format_webhook(glh: &GitlabHook) -> Option<String> {
|
|||
)
|
||||
}
|
||||
_glh => {
|
||||
debug!("Webhook not supported");
|
||||
debug!("Hook not supported");
|
||||
return None;
|
||||
}
|
||||
})
|
10
src/main.rs
10
src/main.rs
|
@ -18,13 +18,13 @@
|
|||
|
||||
mod bot;
|
||||
mod error;
|
||||
mod hook;
|
||||
mod web;
|
||||
mod webhook;
|
||||
|
||||
use crate::bot::XmppClient;
|
||||
use crate::error::Error;
|
||||
use crate::web::webhooks;
|
||||
use crate::webhook::Hook;
|
||||
use crate::hook::Hook;
|
||||
use crate::web::hooks;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{Error as IoError, ErrorKind as IoErrorKind, Read};
|
||||
|
@ -158,7 +158,7 @@ async fn main() -> Result<!, Error> {
|
|||
.serve_connection(io, service_fn(|request| {
|
||||
let value_tx = value_tx.clone();
|
||||
async move {
|
||||
webhooks(request, token, value_tx).await
|
||||
hooks(request, token, value_tx).await
|
||||
}
|
||||
}))
|
||||
.await
|
||||
|
@ -170,7 +170,7 @@ async fn main() -> Result<!, Error> {
|
|||
}
|
||||
wh = value_rx.recv() => {
|
||||
if let Some(Hook::Gitlab(hook)) = wh {
|
||||
client.webhook(hook).await
|
||||
client.hook(hook).await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::webhook::{ForgejoHook, GitlabHook, Hook};
|
||||
use crate::hook::{ForgejoHook, GitlabHook, Hook};
|
||||
|
||||
use std::convert::Infallible;
|
||||
use std::io::Read;
|
||||
|
@ -41,7 +41,7 @@ fn error_res<E: std::fmt::Debug>(e: E) -> Result<Response<Full<Bytes>>, Infallib
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
async fn webhooks_inner(req: Request<Incoming>, token: &str) -> Result<Hook, Error> {
|
||||
async fn hooks_inner(req: Request<Incoming>, token: &str) -> Result<Hook, Error> {
|
||||
match req.method() {
|
||||
&Method::POST => (),
|
||||
_ => return Err(Error::MethodMismatch),
|
||||
|
@ -96,12 +96,12 @@ async fn webhooks_inner(req: Request<Incoming>, token: &str) -> Result<Hook, Err
|
|||
Err(Error::InvalidRequest)
|
||||
}
|
||||
|
||||
pub async fn webhooks(
|
||||
pub async fn hooks(
|
||||
req: Request<Incoming>,
|
||||
token: &str,
|
||||
value_tx: Arc<Mutex<UnboundedSender<Hook>>>,
|
||||
) -> Result<Response<Full<Bytes>>, Infallible> {
|
||||
match webhooks_inner(req, token).await {
|
||||
match hooks_inner(req, token).await {
|
||||
Ok(wh) => {
|
||||
debug!("Passed: {:?}", wh);
|
||||
|
||||
|
|
Loading…
Reference in a new issue