Add accept invitation

This commit is contained in:
Adrian Woźniak 2020-04-21 15:58:25 +02:00
parent 2cb27bb889
commit 219b4d3640

View File

@ -7,6 +7,7 @@ use actix_web::web::Data;
use actix_web::{get, web, Error, HttpRequest, HttpResponse}; use actix_web::{get, web, Error, HttpRequest, HttpResponse};
use actix_web_actors::ws; use actix_web_actors::ws;
use futures::executor::block_on; use futures::executor::block_on;
use futures::SinkExt;
use jirs_data::{ProjectId, Token, UserId, WsMsg}; use jirs_data::{ProjectId, Token, UserId, WsMsg};
@ -266,35 +267,34 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WebSocketActor {
} }
} }
trait MessageHandler {
fn try_message<M>(&self) -> Option<M>
where
M: Message<Result = WsResult>;
}
impl WebSocketActor { impl WebSocketActor {
fn try_handle_message( fn try_handle_message(
&mut self, &mut self,
msg: WsMsg, msg: WsMsg,
ctx: <WebSocketActor as Actor>::Context, _ctx: &mut <WebSocketActor as Actor>::Context,
) -> WsResult { ) -> WsResult
where
Self: Actor,
{
match msg {
WsMsg::InvitationSendRequest { name, email } => {
use invitations::*; use invitations::*;
let m = CreateInvitation {
name: name.clone(),
email: email.clone(),
};
// Handler::handle(&mut self, m, _ctx);
Ok(None) Ok(None)
// match msg { // Handler::<CreateInvitation>::handle(&mut self, m, _ctx)
// WsMsg::InvitationSendRequest { name, email } => self.handle( // <self as Handler<CreateInvitation>>.handle(m, ctx)
// CreateInvitation { }
// name: name.clone(),
// email: email.clone(),
// },
// ctx,
// ),
// WsMsg::InvitationListRequest => self.handle(ListInvitation, ctx), // WsMsg::InvitationListRequest => self.handle(ListInvitation, ctx),
// WsMsg::InvitationAcceptRequest(id) => Ok(None), // WsMsg::InvitationAcceptRequest(id) => Ok(None),
// WsMsg::InvitationRevokeRequest(id) => self.handle(RevokeInvitation { id: *id }, ctx), // WsMsg::InvitationRevokeRequest(id) => self.handle(RevokeInvitation { id: *id }, ctx),
// WsMsg::InvitedUsersRequest => Ok(None), // WsMsg::InvitedUsersRequest => Ok(None),
// _ => Ok(None), _ => Ok(None),
// } }
} }
} }