Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Build Rust docs
run: |
cargo doc -p acter -p acter-core -p matrix-sdk-store-file-event-cache
cargo doc -p acter -p acter-matrix -p acter-core -p matrix-sdk-store-file-event-cache
echo --- Moving docs
mv target/doc/ docs/api/main/rust

Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/check-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
- name: Core
package: acter-core
clippy_extras: --tests
- name: Matrix Core
package: acter-matrix
clippy_extras: --tests
- name: SDK
package: acter
needs_flutter: true
Expand Down Expand Up @@ -51,7 +54,8 @@ jobs:
include:
- name: Core
package: acter-core
clippy_extras: --tests
- name: Matrix Core
package: acter-matrix
# - name: file-event-cache
# package: matrix-sdk-store-file-event-cache
steps:
Expand Down Expand Up @@ -81,9 +85,13 @@ jobs:
strategy:
matrix:
include:
- name: SDK
- name: Matrix SDK
package: acter
needs_flutter: true
- name: Core on WASM
package: acter-core
cargo_flags: --target wasm32-unknown-unknown
needs_flutter: false
steps:
- uses: actions/checkout@v4
- name: Install rust toolchain
Expand All @@ -94,7 +102,7 @@ jobs:
flutter-version: '3.32'
channel: 'stable'
- name: Release Build
run: cargo build -p ${{matrix.package}} --release
run: cargo build -p ${{matrix.package}} --release ${{matrix.cargo_flags}}


ffigen:
Expand Down
17 changes: 17 additions & 0 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ members = [
default-members = ["native/acter"]

[workspace.package]
rust-version = "1.85"
rust-version = "1.88"

[workspace.dependencies.ffi-gen]
git = "https://github.com/acterglobal/ffi-gen"
Expand Down Expand Up @@ -101,6 +101,8 @@ env_logger = "0.11.7"
urlencoding = "2.1.3"
eyeball-im = "0.7.0"

tracing = { version = "0.1.40", features = ["log"] }

[profile.release]
panic = "unwind"
opt-level = 2
Expand Down
6 changes: 5 additions & 1 deletion native/acter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "acter"
version = "0.1.0"
edition = "2021"
rust-version = "1.81"
rust-version = "1.88"
description = "SDK of the acter app"
homepage = "https://acter.global"
repository = "https://github.com/acterglobal/a3"
Expand Down Expand Up @@ -81,6 +81,10 @@ ruma-common = { workspace = true, features = ["client"] }
path = "../matrix"
features = ["templates", "client"]

[dependencies.acter-core]
path = "../core"
features = ["strum"]

[dependencies.matrix-sdk]
workspace = true
features = [
Expand Down
2 changes: 1 addition & 1 deletion native/acter/src/api/activities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Activity {
}

pub fn origin_server_ts(&self) -> u64 {
self.inner.event_meta().origin_server_ts.get().into()
self.inner.event_meta().timestamp.get().into()
}

pub fn room_id_str(&self) -> String {
Expand Down
18 changes: 9 additions & 9 deletions native/acter/src/api/attachments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Attachment {
}

pub fn origin_server_ts(&self) -> u64 {
self.inner.meta.origin_server_ts.get().into()
self.inner.meta.timestamp.get().into()
}

pub fn ref_details(&self) -> Option<RefDetails> {
Expand Down Expand Up @@ -141,7 +141,7 @@ impl Attachment {
.and_then(|info| info.mimetype.as_deref())
.and_then(|mimetype| {
mime2ext::mime2ext(mimetype).map(|ext| {
format!("{}-thumbnail.{}", evt_id, ext)
format!("{evt_id}-thumbnail.{ext}")
})
});
(request, filename)
Expand All @@ -161,7 +161,7 @@ impl Attachment {
.and_then(|info| info.mimetype.as_deref())
.and_then(|mimetype| {
mime2ext::mime2ext(mimetype).map(|ext| {
format!("{}-thumbnail.{}", evt_id, ext)
format!("{evt_id}-thumbnail.{ext}")
})
});
(request, filename)
Expand All @@ -181,7 +181,7 @@ impl Attachment {
.and_then(|info| info.mimetype.as_deref())
.and_then(|mimetype| {
mime2ext::mime2ext(mimetype).map(|ext| {
format!("{}-thumbnail.{}", evt_id, ext)
format!("{evt_id}-thumbnail.{ext}")
})
});
(request, filename)
Expand All @@ -202,7 +202,7 @@ impl Attachment {
.and_then(|info| info.mimetype.as_deref())
.and_then(|mimetype| {
mime2ext::mime2ext(mimetype).map(|ext| {
format!("{}-thumbnail.{}", evt_id, ext)
format!("{evt_id}-thumbnail.{ext}")
})
});
(request, filename)
Expand All @@ -221,7 +221,7 @@ impl Attachment {
.and_then(|info| info.mimetype.as_deref())
.and_then(|mimetype| {
mime2ext::mime2ext(mimetype)
.map(|ext| format!("{}.{}", evt_id, ext))
.map(|ext| format!("{evt_id}.{ext}"))
});
(Some(request), filename)
}
Expand All @@ -236,7 +236,7 @@ impl Attachment {
.and_then(|info| info.mimetype.as_deref())
.and_then(|mimetype| {
mime2ext::mime2ext(mimetype)
.map(|ext| format!("{}.{}", evt_id, ext))
.map(|ext| format!("{evt_id}.{ext}"))
});
(Some(request), filename)
}
Expand All @@ -251,7 +251,7 @@ impl Attachment {
.and_then(|info| info.mimetype.as_deref())
.and_then(|mimetype| {
mime2ext::mime2ext(mimetype)
.map(|ext| format!("{}.{}",evt_id, ext))
.map(|ext| format!("{evt_id}.{ext}"))
});
(Some(request), filename)
}
Expand All @@ -266,7 +266,7 @@ impl Attachment {
.and_then(|info| info.mimetype.as_deref())
.and_then(|mimetype| {
mime2ext::mime2ext(mimetype)
.map(|ext| format!("{}.{}", evt_id, ext))
.map(|ext| format!("{evt_id}.{ext}"))
});
(Some(request), filename)
}
Expand Down
11 changes: 6 additions & 5 deletions native/acter/src/api/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use acter_matrix::{
executor::Executor,
models::AnyActerModel,
referencing::{
ExecuteReference, IndexKey, ModelParam, ObjectListIndex, RoomParam, SectionIndex,
ExecuteReference, IndexKey, IntoExecuteReference, ModelParam, ObjectListIndex, RoomParam,
SectionIndex,
},
store::Store,
templates::Engine,
Expand Down Expand Up @@ -400,7 +401,7 @@ impl Client {

pub fn subscribe_model_stream(&self, key: String) -> Result<impl Stream<Item = bool>> {
let model_id = EventId::parse(key)?;
Ok(BroadcastStream::new(self.subscribe(model_id)).map(|_| true))
Ok(BroadcastStream::new(self.subscribe(model_id.to_owned())).map(|_| true))
}

pub fn subscribe_model_param_stream(
Expand Down Expand Up @@ -433,7 +434,7 @@ impl Client {

pub fn subscribe_room_stream(&self, key: String) -> Result<impl Stream<Item = bool>> {
let model_id = RoomId::parse(key)?;
Ok(BroadcastStream::new(self.subscribe(model_id)).map(|_| true))
Ok(BroadcastStream::new(self.subscribe(model_id.to_owned())).map(|_| true))
}

pub fn subscribe_room_param_stream(
Expand Down Expand Up @@ -486,8 +487,8 @@ impl Client {
)
}

pub fn subscribe<K: Into<ExecuteReference>>(&self, key: K) -> Receiver<()> {
self.executor().subscribe(key)
pub fn subscribe<K: IntoExecuteReference>(&self, key: K) -> Receiver<()> {
self.executor().subscribe(key.into())
}

pub async fn wait_for(&self, key: String, timeout: Option<u8>) -> Result<AnyActerModel> {
Expand Down
14 changes: 11 additions & 3 deletions native/acter/src/api/client/sync.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use acter_matrix::{
events::AnySyncActerEvent, executor::Executor, models::AnyActerModel,
referencing::ExecuteReference, spaces::is_acter_space,
events::AnySyncActerEvent,
executor::Executor,
models::{event_meta_for_redacted_source, AnyActerModel, EventMeta},
referencing::ExecuteReference,
spaces::is_acter_space,
};
use anyhow::Result;
use core::time::Duration;
Expand Down Expand Up @@ -235,7 +238,12 @@ impl Client {

if let RoomRedactionEvent::Original(t) = ev.into_full_event(room_id.to_owned()) {
trace!(?room_id, "received redaction");
if let Err(error) = executor.live_redact(t).await {
let Some(meta) = event_meta_for_redacted_source(&t) else {
warn!(?room_id, "redaction event has no meta");
return;
};

if let Err(error) = executor.live_redact(meta, Some(t.into())).await {
error!(?room_id, ?error, "redaction failed");
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion native/acter/src/api/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Comment {
}

pub fn origin_server_ts(&self) -> u64 {
self.inner.meta.origin_server_ts.get().into()
self.inner.meta.timestamp.get().into()
}

pub fn msg_content(&self) -> MsgContent {
Expand Down
2 changes: 1 addition & 1 deletion native/acter/src/api/invitations/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl InvitationsManager {
// Process each room invitation
match RoomInvitation::parse(&core, room).await {
Ok(invitation) => invites.push(invitation),
Err(err) => log::error!("Failed to parse room invitation: {}", err),
Err(err) => log::error!("Failed to parse room invitation: {err}"),
}
}
invites
Expand Down
2 changes: 1 addition & 1 deletion native/acter/src/api/news.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl NewsEntry {
}

pub fn origin_server_ts(&self) -> u64 {
self.content.meta.origin_server_ts.get().into()
self.content.meta.timestamp.get().into()
}

pub async fn ref_details(&self) -> Result<RefDetails> {
Expand Down
2 changes: 1 addition & 1 deletion native/acter/src/api/reactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Reaction {
}

pub fn origin_server_ts(&self) -> u64 {
self.inner.meta.origin_server_ts.get().into()
self.inner.meta.timestamp.get().into()
}

pub fn relates_to(&self) -> String {
Expand Down
2 changes: 1 addition & 1 deletion native/acter/src/api/rsvp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl Rsvp {
}

pub fn origin_server_ts(&self) -> u64 {
self.inner.meta.origin_server_ts.get().into()
self.inner.meta.timestamp.get().into()
}

pub fn status(&self) -> String {
Expand Down
2 changes: 1 addition & 1 deletion native/acter/src/api/stories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl Story {
}

pub fn origin_server_ts(&self) -> u64 {
self.content.meta.origin_server_ts.get().into()
self.content.meta.timestamp.get().into()
}

pub async fn ref_details(&self) -> Result<RefDetails> {
Expand Down
4 changes: 2 additions & 2 deletions native/acter/src/platform/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ impl Display for MakeStoreConfigError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
MakeStoreConfigError::OpenStoreError(i) => {
write!(f, "MakeStoreConfigError::OpenStoreError {}", i)
write!(f, "MakeStoreConfigError::OpenStoreError {i}")
}
MakeStoreConfigError::EventCacheStoreError(i) => {
write!(f, "MakeStoreConfigError::EventCacheStoreError {}", i)
write!(f, "MakeStoreConfigError::EventCacheStoreError {i}")
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions native/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,26 @@ repository = "https://github.com/acterglobal/a3"
license-file = "../../LICENSE.txt"
rust-version.workspace = true

[features]
testing = [ "tokio/full", "thiserror"]
strum = ["dep:strum"]

[dependencies]
strum = { workspace = true, optional = true }
serde = { version = "1", features = ["derive"] }
tracing = { workspace = true }
async-recursion = "1"
eyeball-im = { workspace = true }
futures = { version = "0.3.30" }
scc = "2.3.4"
tokio = { version = "1" }

# for testing-feature only
thiserror = { version = "2", optional = true }

[dev-dependencies]
serde_json = "1"
tokio = { version = "1", features = ["full"] }
thiserror = "2"
env_logger = "0.11"
anyhow = "1"
Loading
Loading