Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow creation of space.board.post events (WIP) #15

Closed
wants to merge 2 commits into from

Conversation

avdb13
Copy link
Collaborator

@avdb13 avdb13 commented Jan 20, 2024

Provides the handler required to create a post.

@avdb13 avdb13 changed the title feat: allow creation of space.board events (WIP) feat: allow creation of space.board.post events (WIP) Jan 20, 2024
Copy link
Collaborator

@EstebanBorai EstebanBorai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start!

Cargo.toml Outdated
@@ -21,3 +22,6 @@ tracing = "0.1.40"
tracing-subscriber = "0.3.18"
uuid = { version = "1.6.1", features = ["v4"] }
url = "2.4.1"
ruma = { version = "0.9.0", features = ["events", "api", "client", "client-api-c", "rand"] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have feature flags in the Cargo.toml of the crate that uses them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my bad, we can enable certain features per crate? I thought we had to specify feature X Y Z at the root so that crate A can use feature X Y and B feature Z.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the correct way is to specify the dependency without feature flags at the root, but specify the necessary ones per crate?

Comment on lines 27 to 29
ruma = { workspace = true, features = ["events"] }
ruma-common = { workspace = true }
ruma-macros = { workspace = true }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep matrix related dependencies in the matrix crate.

I suggest you reexport or provide wrappers on functions/primitives from ruma that could be transparently replaced without damaging core references.

Comment on lines 1 to 11
use std::sync::Arc;

use futures::future::join_all;
use matrix;
use matrix::admin::resources::room::{ListParams, MessagesParams, RoomService};
use matrix::admin::resources::room_id::RoomId;

use crate::{Result, Error};
use matrix::Client as MatrixAdminClient;
use matrix::client::resources::events::{Events, SendMessageResponse};
use ruma::events::{AnyTimelineEvent, MessageLikeEventContent};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please re-arrange imports by groups.

  1. Standard library
  2. External crates
  3. Local crates (Workspace)
  4. This crate imports

Comment on lines 26 to 27
room_id: impl AsRef<str>,
txn_id: impl AsRef<str>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deplicated constraints. Can we have them in a generic param?

U: AsRef<str>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched to the ID types provided by ruma_events. These provide more context while allowing referenced as well as owned variants.

},
)
.await
.unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid unwraps. Use error handling.

body,
formatted: Some(FormattedBody::html(html_body)),
links: None,
// relates_to: None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// relates_to: None,

Comment on lines 11 to 12
use super::room_id::RoomId;
use crate::http::Client;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit!

Suggested change
use super::room_id::RoomId;
use crate::http::Client;
use crate::http::Client;
use super::room_id::RoomId;

Comment on lines 80 to 81
// should we inline or pull this from `ruma`?
// pub filter: Option<ruma::api::Filter>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we cant expose public fields with private symbols. Then I suggest wrap and provide a valuo if its required as public api.


#[derive(Debug, Default, Serialize)]
pub struct TimestampToEventParams {
pub ts: Option<u64>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have alias for timestamp?

#[derive(Default, Debug, Deserialize)]
pub struct State {
#[serde(rename = "type")]
pub kind: String,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub kind: String,
pub r#type: String,

@EstebanBorai
Copy link
Collaborator

EstebanBorai commented Jan 20, 2024

@avdb13 if this is not ready, I suggest turning into a draft perhaps?

merge: token aware routes with middleware (commune-sh#14)
@avdb13 avdb13 closed this Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants