Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 23745d6829 | |||
| baf52106fd | |||
| 01a1b9a185 |
6 changed files with 28 additions and 4 deletions
|
|
@ -20,7 +20,7 @@ pretty_env_logger = "0.5"
|
||||||
serde = { version = "1.0", features = [ "derive" ] }
|
serde = { version = "1.0", features = [ "derive" ] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
toml = "1.1"
|
toml = "1.1"
|
||||||
xmpp = { git = "https://code.bouah.net/pep/xmpp-rs", rev = "559159d4", default-features = false, features = [ "serde", "starttls", "rustls-native-certs", "aws_lc_rs" ] }
|
xmpp = { git = "https://kl.netlib.re/forge/xmppftw/xmpp-rs", branch = "feat-openssl-vendored", default-features = false, features = [ "serde", "starttls", "rustls-native-certs", "aws_lc_rs" ] }
|
||||||
hmac = "0.13"
|
hmac = "0.13"
|
||||||
sha2 = "0.11"
|
sha2 = "0.11"
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
|
|
@ -36,3 +36,4 @@ forgejo-hooks = { path = "forgejo-hooks" }
|
||||||
[features]
|
[features]
|
||||||
gitlab = [ "dep:gitlab" ]
|
gitlab = [ "dep:gitlab" ]
|
||||||
syntax-highlighting = ["xmpp/syntax-highlighting"]
|
syntax-highlighting = ["xmpp/syntax-highlighting"]
|
||||||
|
vendored-openssl = [ "xmpp/vendored-openssl", "git2/vendored-openssl" ]
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,12 @@ be somewhat of a testbed for xmpp-rs features.
|
||||||
|
|
||||||
Originally based on tokio-webhook2muc.
|
Originally based on tokio-webhook2muc.
|
||||||
|
|
||||||
|
# Cross-compile musl
|
||||||
|
|
||||||
|
```
|
||||||
|
cross build --release --target x86_64-unknown-linux-musl --features vendored-openssl
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
AGPL-3.0-or-later. See the LICENSE file.
|
AGPL-3.0-or-later. See the LICENSE file.
|
||||||
|
|
|
||||||
8
config.sample.toml
Normal file
8
config.sample.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
admins = [ "foo@localhost" ]
|
||||||
|
jid = "bar@localhost"
|
||||||
|
password = "bonjourxmpp"
|
||||||
|
|
||||||
|
rooms = [ "room@muc.localhost" ]
|
||||||
|
secret = "bonjourforgejo"
|
||||||
|
|
||||||
|
addr = "[::1]:5225"
|
||||||
|
|
@ -77,6 +77,7 @@ impl From<FjIssue> for Note {
|
||||||
.comment
|
.comment
|
||||||
.map(|c| c.html_url)
|
.map(|c| c.html_url)
|
||||||
.unwrap_or(other.issue.html_url),
|
.unwrap_or(other.issue.html_url),
|
||||||
|
is_update: other.action == FjIssueAction::Edited,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,19 +109,26 @@ pub fn format_hook(hook: &Hook) -> Option<String> {
|
||||||
if note.snippet {
|
if note.snippet {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let updated_fmt = if note.is_update {
|
||||||
|
"updated comment"
|
||||||
|
} else {
|
||||||
|
"commented"
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(commit) = ¬e.commit {
|
if let Some(commit) = ¬e.commit {
|
||||||
format!(
|
format!(
|
||||||
"[{}] {} commented on commit {:?} <{}>",
|
"[{}] {} {updated_fmt} on commit {:?} <{}>",
|
||||||
note.repository.name, note.author.name, commit.ref_, commit.url,
|
note.repository.name, note.author.name, commit.ref_, commit.url,
|
||||||
)
|
)
|
||||||
} else if let Some(issue) = ¬e.issue {
|
} else if let Some(issue) = ¬e.issue {
|
||||||
format!(
|
format!(
|
||||||
"[{}] {} commented on issue {}: {} <{}>",
|
"[{}] {} {updated_fmt} on issue {}: {} <{}>",
|
||||||
note.repository.name, note.author.name, issue.id, issue.title, note.url,
|
note.repository.name, note.author.name, issue.id, issue.title, note.url,
|
||||||
)
|
)
|
||||||
} else if let Some(mr) = ¬e.merge_request {
|
} else if let Some(mr) = ¬e.merge_request {
|
||||||
format!(
|
format!(
|
||||||
"[{}] {} commented on merge request {}: {} <{}>",
|
"[{}] {} {updated_fmt} on merge request {}: {} <{}>",
|
||||||
note.repository.name, note.author.name, mr.id, mr.title, note.url,
|
note.repository.name, note.author.name, mr.id, mr.title, note.url,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ pub struct Note {
|
||||||
pub repository: Repository,
|
pub repository: Repository,
|
||||||
pub author: User,
|
pub author: User,
|
||||||
pub url: String,
|
pub url: String,
|
||||||
|
pub is_update: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue