revert changes to notification interface

pull/5320/head
Stefan Melmuk 7 days ago
parent 3ae88b3eca
commit e361d2445b
No known key found for this signature in database
GPG Key ID: 817020C608FE9C09

@ -418,7 +418,7 @@ async fn delete_user(uuid: UserId, token: AdminToken, mut conn: DbConn) -> Empty
async fn deauth_user(uuid: UserId, _token: AdminToken, mut conn: DbConn, nt: Notify<'_>) -> EmptyResult {
let mut user = get_user_or_404(&uuid, &mut conn).await?;
nt.send_logout(&user, &DeviceId::empty()).await;
nt.send_logout(&user, None).await;
if CONFIG.push_enabled() {
for device in Device::find_push_devices_by_user(&user.uuid, &mut conn).await {
@ -444,7 +444,7 @@ async fn disable_user(uuid: UserId, _token: AdminToken, mut conn: DbConn, nt: No
let save_result = user.save(&mut conn).await;
nt.send_logout(&user, &DeviceId::empty()).await;
nt.send_logout(&user, None).await;
save_result
}

@ -374,7 +374,7 @@ async fn post_password(data: Json<ChangePassData>, headers: Headers, mut conn: D
// Prevent logging out the client where the user requested this endpoint from.
// If you do logout the user it will causes issues at the client side.
// Adding the device uuid will prevent this.
nt.send_logout(&user, &headers.device.uuid).await;
nt.send_logout(&user, Some(headers.device.uuid.to_string())).await;
save_result
}
@ -434,7 +434,7 @@ async fn post_kdf(data: Json<ChangeKdfData>, headers: Headers, mut conn: DbConn,
user.set_password(&data.new_master_password_hash, Some(data.key), true, None);
let save_result = user.save(&mut conn).await;
nt.send_logout(&user, &headers.device.uuid).await;
nt.send_logout(&user, Some(headers.device.uuid.to_string())).await;
save_result
}
@ -646,7 +646,7 @@ async fn post_rotatekey(data: Json<KeyData>, headers: Headers, mut conn: DbConn,
// Prevent logging out the client where the user requested this endpoint from.
// If you do logout the user it will causes issues at the client side.
// Adding the device uuid will prevent this.
nt.send_logout(&user, &headers.device.uuid).await;
nt.send_logout(&user, Some(headers.device.uuid.to_string())).await;
save_result
}
@ -662,7 +662,7 @@ async fn post_sstamp(data: Json<PasswordOrOtpData>, headers: Headers, mut conn:
user.reset_security_stamp();
let save_result = user.save(&mut conn).await;
nt.send_logout(&user, &DeviceId::empty()).await;
nt.send_logout(&user, None).await;
save_result
}
@ -770,7 +770,7 @@ async fn post_email(data: Json<ChangeEmailData>, headers: Headers, mut conn: DbC
let save_result = user.save(&mut conn).await;
nt.send_logout(&user, &DeviceId::empty()).await;
nt.send_logout(&user, None).await;
save_result
}

@ -2860,7 +2860,7 @@ async fn put_reset_password(
user.set_password(reset_request.new_master_password_hash.as_str(), Some(reset_request.key), true, None);
user.save(&mut conn).await?;
nt.send_logout(&user, &DeviceId::empty()).await;
nt.send_logout(&user, None).await;
log_event(
EventType::OrganizationUserAdminResetPassword as i32,

@ -485,7 +485,7 @@ async fn post_access(
UpdateType::SyncSendUpdate,
&send,
&send.update_users_revision(&mut conn).await,
&DeviceId::empty(),
&String::from("00000000-0000-0000-0000-000000000000").into(),
&mut conn,
)
.await;
@ -542,7 +542,7 @@ async fn post_access_file(
UpdateType::SyncSendUpdate,
&send,
&send.update_users_revision(&mut conn).await,
&DeviceId::empty(),
&String::from("00000000-0000-0000-0000-000000000000").into(),
&mut conn,
)
.await;
@ -635,7 +635,7 @@ pub async fn update_send_from_data(
send.save(conn).await?;
if ut != UpdateType::None {
nt.send_send_update(ut, send, &send.update_users_revision(conn).await, &headers.device.uuid, conn).await
nt.send_send_update(ut, send, &send.update_users_revision(conn).await, &headers.device.uuid, conn).await;
}
Ok(())
}

@ -347,7 +347,7 @@ impl WebSocketUsers {
let data = create_update(
vec![("UserId".into(), user.uuid.to_string().into()), ("Date".into(), serialize_date(user.updated_at))],
ut,
DeviceId::empty(),
None,
);
if CONFIG.enable_websocket() {
@ -359,7 +359,7 @@ impl WebSocketUsers {
}
}
pub async fn send_logout(&self, user: &User, acting_device_uuid: &DeviceId) {
pub async fn send_logout(&self, user: &User, acting_device_uuid: Option<String>) {
// Skip any processing if both WebSockets and Push are not active
if *NOTIFICATIONS_DISABLED {
return;
@ -397,7 +397,7 @@ impl WebSocketUsers {
("RevisionDate".into(), serialize_date(folder.updated_at)),
],
ut,
acting_device_uuid.clone(),
Some(acting_device_uuid.to_string()),
);
if CONFIG.enable_websocket() {
@ -444,7 +444,7 @@ impl WebSocketUsers {
("RevisionDate".into(), revision_date),
],
ut,
acting_device_uuid.clone(),
Some(acting_device_uuid.to_string()),
);
if CONFIG.enable_websocket() {
@ -479,7 +479,7 @@ impl WebSocketUsers {
("RevisionDate".into(), serialize_date(send.revision_date)),
],
ut,
acting_device_uuid.clone(),
None,
);
if CONFIG.enable_websocket() {
@ -506,7 +506,7 @@ impl WebSocketUsers {
let data = create_update(
vec![("Id".into(), auth_request_uuid.clone().into()), ("UserId".into(), user_uuid.to_string().into())],
UpdateType::AuthRequest,
acting_device_uuid.clone(),
Some(acting_device_uuid.to_string()),
);
if CONFIG.enable_websocket() {
self.send_update(user_uuid, &data).await;
@ -531,7 +531,7 @@ impl WebSocketUsers {
let data = create_update(
vec![("Id".into(), auth_response_uuid.to_owned().into()), ("UserId".into(), user_uuid.to_string().into())],
UpdateType::AuthRequestResponse,
approving_device_uuid.clone(),
Some(approving_device_uuid.to_string()),
);
if CONFIG.enable_websocket() {
self.send_update(user_uuid, &data).await;
@ -585,7 +585,7 @@ impl AnonymousWebSocketSubscriptions {
]
]
*/
fn create_update(payload: Vec<(Value, Value)>, ut: UpdateType, acting_device_uuid: DeviceId) -> Vec<u8> {
fn create_update(payload: Vec<(Value, Value)>, ut: UpdateType, acting_device_uuid: Option<String>) -> Vec<u8> {
use rmpv::Value as V;
let value = V::Array(vec![
@ -594,7 +594,7 @@ fn create_update(payload: Vec<(Value, Value)>, ut: UpdateType, acting_device_uui
V::Nil,
"ReceiveMessage".into(),
V::Array(vec![V::Map(vec![
("ContextId".into(), acting_device_uuid.to_string().into()),
("ContextId".into(), acting_device_uuid.map(|v| v.into()).unwrap_or_else(|| V::Nil)),
("Type".into(), (ut as i32).into()),
("Payload".into(), payload.into()),
])]),

@ -178,8 +178,8 @@ pub async fn push_cipher_update(
}
}
pub fn push_logout(user: &User, acting_device_uuid: DeviceId) {
let acting_device_uuid: Value = acting_device_uuid.to_string().into();
pub fn push_logout(user: &User, acting_device_uuid: Option<String>) {
let acting_device_uuid: Value = acting_device_uuid.map(|v| v.into()).unwrap_or_else(|| Value::Null);
tokio::task::spawn(send_to_push_relay(json!({
"userId": user.uuid,

@ -338,12 +338,6 @@ impl DeviceType {
#[derive(Clone, Debug, DieselNewType, Display, From, FromForm, Hash, PartialEq, Eq, Serialize, Deserialize)]
pub struct DeviceId(String);
impl DeviceId {
pub fn empty() -> Self {
Self(String::from("00000000-0000-0000-0000-000000000000"))
}
}
impl<'r> FromParam<'r> for DeviceId {
type Error = ();

Loading…
Cancel
Save