[fractal] Invite users through matrix-sdk
- From: Alexandre Franke <afranke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] Invite users through matrix-sdk
- Date: Tue, 1 Dec 2020 20:21:59 +0000 (UTC)
commit e69a0c733c05afa707e72bc520163397ab9f9480
Author: Alejandro DomÃnguez <adomu net-c com>
Date: Sat Aug 15 05:16:04 2020 +0200
Invite users through matrix-sdk
fractal-gtk/src/appop/invite.rs | 8 +++---
fractal-gtk/src/backend/room.rs | 24 ++++++-----------
fractal-matrix-api/src/meson.build | 2 --
fractal-matrix-api/src/r0.rs | 1 -
fractal-matrix-api/src/r0/membership.rs | 1 -
.../src/r0/membership/invite_user.rs | 30 ----------------------
6 files changed, 11 insertions(+), 55 deletions(-)
---
diff --git a/fractal-gtk/src/appop/invite.rs b/fractal-gtk/src/appop/invite.rs
index 8942effd..5563bea5 100644
--- a/fractal-gtk/src/appop/invite.rs
+++ b/fractal-gtk/src/appop/invite.rs
@@ -3,7 +3,6 @@ use crate::util::i18n::{i18n, i18n_k};
use crate::backend::room;
use fractal_api::identifiers::{RoomId, UserId};
use gtk::prelude::*;
-use std::thread;
use crate::app::{App, RUNTIME};
use crate::appop::member::SearchType;
@@ -165,12 +164,11 @@ impl AppOp {
let login_data = unwrap_or_unit_return!(self.login_data.clone());
if let Some(ref r) = self.active_room {
for user in &self.invite_list {
- let server = login_data.session_client.homeserver().clone();
- let access_token = login_data.access_token.clone();
+ let session_client = login_data.session_client.clone();
let room_id = r.clone();
let user_id = user.0.uid.clone();
- thread::spawn(move || {
- let query = room::invite(server, access_token, room_id, user_id);
+ RUNTIME.spawn(async move {
+ let query = room::invite(session_client, &room_id, &user_id).await;
if let Err(err) = query {
err.handle_error();
}
diff --git a/fractal-gtk/src/backend/room.rs b/fractal-gtk/src/backend/room.rs
index 79de0e1b..369333d6 100644
--- a/fractal-gtk/src/backend/room.rs
+++ b/fractal-gtk/src/backend/room.rs
@@ -37,9 +37,6 @@ use fractal_api::r0::filter::RoomEventFilter;
use fractal_api::r0::media::create_content::request as create_content;
use fractal_api::r0::media::create_content::Parameters as CreateContentParameters;
use fractal_api::r0::media::create_content::Response as CreateContentResponse;
-use fractal_api::r0::membership::invite_user::request as invite_user;
-use fractal_api::r0::membership::invite_user::Body as InviteUserBody;
-use fractal_api::r0::membership::invite_user::Parameters as InviteUserParameters;
use fractal_api::r0::message::create_message_event::request as create_message_event;
use fractal_api::r0::message::create_message_event::Parameters as CreateMessageEventParameters;
use fractal_api::r0::message::create_message_event::Response as CreateMessageEventResponse;
@@ -835,27 +832,22 @@ pub fn add_to_fav(
}
#[derive(Debug)]
-pub struct InviteError(ReqwestError);
+pub struct InviteError(MatrixError);
-impl From<ReqwestError> for InviteError {
- fn from(err: ReqwestError) -> Self {
+impl From<MatrixError> for InviteError {
+ fn from(err: MatrixError) -> Self {
Self(err)
}
}
impl HandleError for InviteError {}
-pub fn invite(
- base: Url,
- access_token: AccessToken,
- room_id: RoomId,
- user_id: UserId,
+pub async fn invite(
+ session_client: MatrixClient,
+ room_id: &RoomId,
+ user_id: &UserId,
) -> Result<(), InviteError> {
- let params = InviteUserParameters { access_token };
- let body = InviteUserBody { user_id };
-
- let request = invite_user(base, &room_id, ¶ms, &body)?;
- HTTP_CLIENT.get_client().execute(request)?;
+ session_client.invite_user_by_id(room_id, user_id).await?;
Ok(())
}
diff --git a/fractal-matrix-api/src/meson.build b/fractal-matrix-api/src/meson.build
index ddfb163d..9d60f08a 100644
--- a/fractal-matrix-api/src/meson.build
+++ b/fractal-matrix-api/src/meson.build
@@ -21,7 +21,6 @@ api_sources = files(
'r0/media/create_content.rs',
'r0/media/get_content.rs',
'r0/media/get_content_thumbnail.rs',
- 'r0/membership/invite_user.rs',
'r0/message/create_message_event.rs',
'r0/message/get_message_events.rs',
'r0/profile/get_display_name.rs',
@@ -47,7 +46,6 @@ api_sources = files(
'r0/directory.rs',
'r0/filter.rs',
'r0/media.rs',
- 'r0/membership.rs',
'r0/message.rs',
'r0/profile.rs',
'r0/read_marker.rs',
diff --git a/fractal-matrix-api/src/r0.rs b/fractal-matrix-api/src/r0.rs
index 2bc9f0a2..4d46e6b8 100644
--- a/fractal-matrix-api/src/r0.rs
+++ b/fractal-matrix-api/src/r0.rs
@@ -5,7 +5,6 @@ pub mod context;
pub mod directory;
pub mod filter;
pub mod media;
-pub mod membership;
pub mod message;
pub mod profile;
pub mod pushrules;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]