Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Jan 14, 2025
1 parent 343a5cd commit e1b4c9b
Show file tree
Hide file tree
Showing 11 changed files with 886 additions and 650 deletions.
1,360 changes: 794 additions & 566 deletions Cargo.lock

Large diffs are not rendered by default.

44 changes: 21 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,39 @@ name = "notify_push"
version = "0.1.0" # this version number is unused, the version number for the binary will be extracted from the appinfo/info.xml during build
authors = ["Robin Appelman <[email protected]>"]
edition = "2021"
rust-version = "1.74.1"
rust-version = "1.77.2"

[dependencies]
redis = { version = "0.26.0", default-features = false, features = ["tokio-comp", "aio", "cluster", "cluster-async", "keep-alive"] }
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.120"
thiserror = "1.0.63"
redis = { version = "0.28.1", default-features = false, features = ["tokio-comp", "aio", "cluster", "cluster-async", "keep-alive"] }
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.135"
thiserror = "2.0.11"
warp = { version = "0.3.7", features = ["tls"] }
tokio = { version = "1.39.1", features = ["macros", "rt-multi-thread", "signal"] }
futures = "0.3.30"
log = "0.4.22"
sqlx = { version = "0.8.0", features = ["runtime-tokio-rustls", "any", "mysql", "sqlite", "postgres"] }
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread", "signal"] }
futures = "0.3.31"
log = "0.4.25"
sqlx = { version = "0.8.3", features = ["runtime-tokio-rustls", "any", "mysql", "sqlite", "postgres"] }
dotenvy = "0.15.7"
dashmap = "6.0.1"
once_cell = "1.19.0"
miette = { version = "7.2.0", features = ["fancy"] }
dashmap = "6.1.0"
once_cell = "1.20.2"
miette = { version = "7.4.0", features = ["fancy"] }
smallvec = { version = "1.13.2", features = ["serde"] }
reqwest = { version = "0.12.5", default-features = false, features = ["rustls-tls", "json"] }
reqwest = { version = "0.12.12", default-features = false, features = ["rustls-tls", "json"] }
warp-real-ip = "0.2.0"
parse-display = "0.9.1"
percent-encoding = "2.3.1"
rand = { version = "0.8.5", features = ["small_rng"] }
ahash = "0.8.11"
flexi_logger = { version = "0.28.5", features = ["colors"] }
tokio-stream = { version = "0.1.15", features = ["net"] }
derivative = "2.2.0"
nextcloud-config-parser = { version = "0.11.0", features = ["redis-connect"] }
url = "2.5.2"
clap = { version = "4.5.11", features = ["derive"] }
sd-notify = { version = "0.4.2", optional = true }
flexi_logger = { version = "0.29.8", features = ["colors"] }
tokio-stream = { version = "0.1.17", features = ["net"] }
nextcloud-config-parser = { version = "0.12.0", features = ["redis-connect"] }
url = "2.5.4"
clap = { version = "4.5.26", features = ["derive"] }
sd-notify = { version = "0.4.3", optional = true }

[dev-dependencies]
mini-redis = "0.4.1"
tokio-tungstenite = "0.23.1"
http-auth-basic = "0.3.3"
tokio-tungstenite = "0.26.1"
http-auth-basic = "0.3.5"
test_client = { path = "test_client" }

[build-dependencies]
Expand Down
31 changes: 20 additions & 11 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->

# Developing

As developer of a Nextcloud app or client you can use the `notify_push` app to receive real time notifications from the
Expand All @@ -14,7 +15,7 @@ you can use the [`@nextcloud/notify_push`](https://www.npmjs.com/package/@nextcl
Which will handle all the details for authenticating and connecting to the push server.

```js
import { listen } from '@nextcloud/notify_push'
import {listen} from '@nextcloud/notify_push'

let has_push = listen('notify_file', () => {
console.log("A file has been changed")
Expand All @@ -27,7 +28,8 @@ if (!hash_push) {

## Clients

Desktop and other clients that don't run in the Nextcloud web interface can use the following steps to receive notifications.
Desktop and other clients that don't run in the Nextcloud web interface can use the following steps to receive
notifications.

- Get the push server url from the `notify_push` capability by sending an authenticated request
to `https://cloud.example.com/ocs/v2.php/cloud/capabilities`
Expand All @@ -40,10 +42,13 @@ Desktop and other clients that don't run in the Nextcloud web interface can use
- "notify_activity" when a new activity item for a user is created (note, due to workings of the activity app, file
related activity doesn't trigger this notification)
- "notify_notification" when a notification is created, processed or dismissed for a user
- Starting with version 0.4 you can opt into receiving the changed file ids for file update notifications by sending `listen notify_file_id` over the websocket.
Once enabled, the server will send "notify_file_id" followed by a json encoded array of file ids if the push server knows
- Starting with version 0.4 you can opt into receiving the changed file ids for file update notifications by sending
`listen notify_file_id` over the websocket.
Once enabled, the server will send "notify_file_id" followed by a json encoded array of file ids if the push server
knows
the ids of the changed files.
In cases where there push server doesn't know which files have changed, it will send the regular "notify_file" message.
In cases where there push server doesn't know which files have changed, it will send the regular "notify_file"
message.

### Example

Expand Down Expand Up @@ -87,7 +92,8 @@ discover_endpoint(nextcloud_url, username, password).then((endpoint) => {

## Pre-authenticated tokens

In situations where you don't have the user credentials but you can send authenticated requests to nextcloud(such as when you have authenticated cookies)
In situations where you don't have the user credentials but you can send authenticated requests to nextcloud(such as
when you have authenticated cookies)
you can use "pre-authenticated tokens" instead of the username and password.

- Get the `pre_auth` endpoint from the ocs capabilities request
Expand All @@ -110,10 +116,11 @@ $queue->push('notify_custom', [
]);
```

Which will be pushed to client as `'my_message_type {"foo": "bar"}'` and can be used with the `@nextcloud/notify_push` client using
Which will be pushed to client as `'my_message_type {"foo": "bar"}'` and can be used with the `@nextcloud/notify_push`
client using

```js
import { listen } from '@nextcloud/notify_push'
import {listen} from '@nextcloud/notify_push'

listen('my_message_type', (message_type, optional_body) => {

Expand All @@ -122,7 +129,7 @@ listen('my_message_type', (message_type, optional_body) => {

## Building

The server binary is built using rust and cargo, and requires a minimum of rust `1.74`.
The server binary is built using rust and cargo, and requires a minimum of rust `1.77`.

- Install `rust` through your package manager or [rustup](https://rustup.rs/)
- Run `cargo build`
Expand All @@ -138,5 +145,7 @@ cargo build --release --target=x86_64-unknown-linux-musl

Cross compiling to other platforms can be done using two ways:

- using [`nix`](https://nixos.org/download.html) and `nix build .#aarch64-unknown-linux-musl` (recommended, binaries can be found in `./result/bin`)
- using [`cross`](https://github.com/rust-embedded/cross) and `cross build --release --target=aarch64-unknown-linux-musl`
- using [`nix`](https://nixos.org/download.html) and `nix build .#aarch64-unknown-linux-musl` (recommended, binaries can
be found in `./result/bin`)
- using [`cross`](https://github.com/rust-embedded/cross) and
`cross build --release --target=aarch64-unknown-linux-musl`
35 changes: 16 additions & 19 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
naersk.inputs.nixpkgs.follows = "nixpkgs";
Expand Down Expand Up @@ -116,7 +116,7 @@
devShells = {
default = cross-naersk'.mkShell targets {
nativeBuildInputs = with pkgs; [
(rust-bin.beta.latest.default.override {targets = targets ++ [hostTarget];})
(rust-bin.stable.latest.default.override {targets = targets ++ [hostTarget];})
krankerl
cargo-edit
cargo-outdated
Expand Down
28 changes: 16 additions & 12 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ use crate::{Error, Result};
use clap::builder::styling::{AnsiColor, Effects};
use clap::builder::Styles;
use clap::Parser;
use derivative::Derivative;
use redis::ConnectionInfo;
use sqlx::any::AnyConnectOptions;
use std::convert::{TryFrom, TryInto};
use std::env::var;
use std::fmt::{Display, Formatter};
use std::fmt::{Debug, Display, Formatter};
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::path::{Path, PathBuf};
use std::str::FromStr;
Expand Down Expand Up @@ -119,25 +118,30 @@ pub struct TlsConfig {
pub cert: PathBuf,
}

#[derive(Clone, Derivative)]
#[derivative(Debug)]
#[derive(Clone)]
pub enum Bind {
Tcp(SocketAddr),
Unix(
PathBuf,
#[derivative(Debug(format_with = "format_permissions"))] u32,
),
Unix(PathBuf, u32),
}

fn format_permissions(permissions: &u32, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "0{:o}", permissions)
impl Debug for Bind {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Bind::Tcp(addr) => f.debug_tuple("Tcp").field(addr).finish(),
Bind::Unix(path, permissions) => f
.debug_tuple("Unix")
.field(path)
.field(&format!("0{:0}", permissions))
.finish(),
}
}
}

impl Display for Bind {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Bind::Tcp(addr) => addr.fmt(f),
Bind::Unix(path, _) => path.to_string_lossy().fmt(f),
Bind::Tcp(addr) => Display::fmt(addr, f),
Bind::Unix(path, _) => Display::fmt(&path.display(), f),
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

use crate::error::ConfigError;
use crate::Result;
use redis::aio::{MultiplexedConnection, PubSub};
Expand Down Expand Up @@ -58,10 +58,10 @@ impl RedisConnection {
pub async fn del(&mut self, key: &str) -> Result<(), RedisError> {
match self {
RedisConnection::Single(client) => {
client.del(key).await?;
client.del::<_, ()>(key).await?;
}
RedisConnection::Cluster(client) => {
client.del(key).await?;
client.del::<_, ()>(key).await?;
}
}
Ok(())
Expand All @@ -77,10 +77,10 @@ impl RedisConnection {
pub async fn set(&mut self, key: &str, value: &str) -> Result<()> {
match self {
RedisConnection::Single(client) => {
client.set(key, value).await?;
client.set::<_, _, ()>(key, value).await?;
}
RedisConnection::Cluster(client) => {
client.set(key, value).await?;
client.set::<_, _, ()>(key, value).await?;
}
}
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<'de> Deserialize<'de> for UserId {
{
struct UserIdVisitor;

impl<'a> Visitor<'a> for UserIdVisitor {
impl Visitor<'_> for UserIdVisitor {
type Value = UserId;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
14 changes: 7 additions & 7 deletions test_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ authors = ["Robin Appelman <[email protected]>"]
edition = "2018"

[dependencies]
tungstenite = { version = "0.23.0", features = ["rustls-tls-webpki-roots", "url"] }
serde_json = "1.0.120"
ureq = "2.10.0"
flexi_logger = { version = "0.28.5", features = ["colors"] }
log = "0.4.22"
tungstenite = { version = "0.26.1", features = ["rustls-tls-webpki-roots", "url"] }
serde_json = "1.0.135"
ureq = "2.12.1"
flexi_logger = { version = "0.29.8", features = ["colors"] }
log = "0.4.25"
base64 = "0.22.1"
miette = { version = "7.2.0", features = ["fancy"] }
url = "2.5.2"
miette = { version = "7.4.0", features = ["fancy"] }
url = "2.5.4"
4 changes: 2 additions & 2 deletions test_client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ fn main() -> Result<()> {
.wrap_err("Can't connect to server")?;

socket
.send(Message::Text(username))
.send(Message::Text(username.into()))
.into_diagnostic()
.wrap_err("Failed to send username")?;
socket
.send(Message::Text(password))
.send(Message::Text(password.into()))
.into_diagnostic()
.wrap_err("Failed to send password")?;
socket
Expand Down
Loading

0 comments on commit e1b4c9b

Please sign in to comment.