|
|
@ -139,71 +139,52 @@ pub async fn push_cipher_update(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
for device in Device::find_by_user(user_uuid, conn).await {
|
|
|
|
if Device::check_user_has_push_device(user_uuid, conn).await {
|
|
|
|
let data = json!({
|
|
|
|
send_to_push_relay(json!({
|
|
|
|
"userId": user_uuid,
|
|
|
|
"userId": user_uuid,
|
|
|
|
"organizationId": (),
|
|
|
|
"organizationId": (),
|
|
|
|
"deviceId": device.push_uuid,
|
|
|
|
"deviceId": acting_device_uuid,
|
|
|
|
"identifier": acting_device_uuid,
|
|
|
|
"identifier": acting_device_uuid,
|
|
|
|
"type": ut as i32,
|
|
|
|
"type": ut as i32,
|
|
|
|
"payload": {
|
|
|
|
"payload": {
|
|
|
|
"Id": cipher.uuid,
|
|
|
|
"id": cipher.uuid,
|
|
|
|
"UserId": cipher.user_uuid,
|
|
|
|
"userId": cipher.user_uuid,
|
|
|
|
"OrganizationId": (),
|
|
|
|
"organizationId": (),
|
|
|
|
"RevisionDate": cipher.updated_at
|
|
|
|
"revisionDate": cipher.updated_at
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}))
|
|
|
|
|
|
|
|
.await;
|
|
|
|
send_to_push_relay(data).await;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn push_logout(user: &User, acting_device_uuid: Option<String>, conn: &mut crate::db::DbConn) {
|
|
|
|
pub fn push_logout(user: &User, acting_device_uuid: Option<String>) {
|
|
|
|
if let Some(d) = acting_device_uuid {
|
|
|
|
let acting_device_uuid: Value = acting_device_uuid.map(|v| v.into()).unwrap_or_else(|| Value::Null);
|
|
|
|
for device in Device::find_by_user(&user.uuid, conn).await {
|
|
|
|
|
|
|
|
let data = json!({
|
|
|
|
tokio::task::spawn(send_to_push_relay(json!({
|
|
|
|
"userId": user.uuid,
|
|
|
|
"userId": user.uuid,
|
|
|
|
"organizationId": (),
|
|
|
|
"organizationId": (),
|
|
|
|
"deviceId": device.push_uuid,
|
|
|
|
"deviceId": acting_device_uuid,
|
|
|
|
"identifier": d,
|
|
|
|
"identifier": acting_device_uuid,
|
|
|
|
"type": UpdateType::LogOut as i32,
|
|
|
|
"type": UpdateType::LogOut as i32,
|
|
|
|
"payload": {
|
|
|
|
"payload": {
|
|
|
|
"UserId": user.uuid,
|
|
|
|
|
|
|
|
"Date": user.updated_at
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
send_to_push_relay(data).await;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
let data = json!({
|
|
|
|
|
|
|
|
"userId": user.uuid,
|
|
|
|
"userId": user.uuid,
|
|
|
|
"organizationId": (),
|
|
|
|
"date": user.updated_at
|
|
|
|
"deviceId": (),
|
|
|
|
}
|
|
|
|
"identifier": (),
|
|
|
|
})));
|
|
|
|
"type": UpdateType::LogOut as i32,
|
|
|
|
|
|
|
|
"payload": {
|
|
|
|
|
|
|
|
"UserId": user.uuid,
|
|
|
|
|
|
|
|
"Date": user.updated_at
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
send_to_push_relay(data).await;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn push_user_update(ut: UpdateType, user: &User) {
|
|
|
|
pub fn push_user_update(ut: UpdateType, user: &User) {
|
|
|
|
let data = json!({
|
|
|
|
tokio::task::spawn(send_to_push_relay(json!({
|
|
|
|
"userId": user.uuid,
|
|
|
|
"userId": user.uuid,
|
|
|
|
"organizationId": (),
|
|
|
|
"organizationId": (),
|
|
|
|
"deviceId": (),
|
|
|
|
"deviceId": (),
|
|
|
|
"identifier": (),
|
|
|
|
"identifier": (),
|
|
|
|
"type": ut as i32,
|
|
|
|
"type": ut as i32,
|
|
|
|
"payload": {
|
|
|
|
"payload": {
|
|
|
|
"UserId": user.uuid,
|
|
|
|
"userId": user.uuid,
|
|
|
|
"Date": user.updated_at
|
|
|
|
"date": user.updated_at
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})));
|
|
|
|
|
|
|
|
|
|
|
|
send_to_push_relay(data).await;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn push_folder_update(
|
|
|
|
pub async fn push_folder_update(
|
|
|
@ -212,46 +193,42 @@ pub async fn push_folder_update(
|
|
|
|
acting_device_uuid: &String,
|
|
|
|
acting_device_uuid: &String,
|
|
|
|
conn: &mut crate::db::DbConn,
|
|
|
|
conn: &mut crate::db::DbConn,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
for device in Device::find_by_user(&folder.user_uuid, conn).await {
|
|
|
|
if Device::check_user_has_push_device(&folder.user_uuid, conn).await {
|
|
|
|
let data = json!({
|
|
|
|
tokio::task::spawn(send_to_push_relay(json!({
|
|
|
|
"userId": folder.user_uuid,
|
|
|
|
"userId": folder.user_uuid,
|
|
|
|
"organizationId": (),
|
|
|
|
"organizationId": (),
|
|
|
|
"deviceId": device.push_uuid,
|
|
|
|
"deviceId": acting_device_uuid,
|
|
|
|
"identifier": acting_device_uuid,
|
|
|
|
"identifier": acting_device_uuid,
|
|
|
|
"type": ut as i32,
|
|
|
|
"type": ut as i32,
|
|
|
|
"payload": {
|
|
|
|
"payload": {
|
|
|
|
"Id": folder.uuid,
|
|
|
|
"id": folder.uuid,
|
|
|
|
"UserId": folder.user_uuid,
|
|
|
|
"userId": folder.user_uuid,
|
|
|
|
"RevisionDate": folder.updated_at
|
|
|
|
"revisionDate": folder.updated_at
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})));
|
|
|
|
|
|
|
|
|
|
|
|
send_to_push_relay(data).await;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn push_send_update(ut: UpdateType, send: &Send, conn: &mut crate::db::DbConn) {
|
|
|
|
pub async fn push_send_update(ut: UpdateType, send: &Send, acting_device_uuid: &String, conn: &mut crate::db::DbConn) {
|
|
|
|
if let Some(s) = &send.user_uuid {
|
|
|
|
if let Some(s) = &send.user_uuid {
|
|
|
|
for device in Device::find_by_user(s, conn).await {
|
|
|
|
if Device::check_user_has_push_device(s, conn).await {
|
|
|
|
let data = json!({
|
|
|
|
tokio::task::spawn(send_to_push_relay(json!({
|
|
|
|
"userId": send.user_uuid,
|
|
|
|
"userId": send.user_uuid,
|
|
|
|
"organizationId": (),
|
|
|
|
"organizationId": (),
|
|
|
|
"deviceId": device.push_uuid,
|
|
|
|
"deviceId": acting_device_uuid,
|
|
|
|
"identifier": (),
|
|
|
|
"identifier": acting_device_uuid,
|
|
|
|
"type": ut as i32,
|
|
|
|
"type": ut as i32,
|
|
|
|
"payload": {
|
|
|
|
"payload": {
|
|
|
|
"Id": send.uuid,
|
|
|
|
"id": send.uuid,
|
|
|
|
"UserId": send.user_uuid,
|
|
|
|
"userId": send.user_uuid,
|
|
|
|
"RevisionDate": send.revision_date
|
|
|
|
"revisionDate": send.revision_date
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})));
|
|
|
|
|
|
|
|
|
|
|
|
send_to_push_relay(data).await;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn send_to_push_relay(data: Value) {
|
|
|
|
async fn send_to_push_relay(notification_data: Value) {
|
|
|
|
if !CONFIG.push_enabled() {
|
|
|
|
if !CONFIG.push_enabled() {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -270,8 +247,8 @@ async fn send_to_push_relay(data: Value) {
|
|
|
|
.post(CONFIG.push_relay_uri() + "/push/send")
|
|
|
|
.post(CONFIG.push_relay_uri() + "/push/send")
|
|
|
|
.header(ACCEPT, "application/json")
|
|
|
|
.header(ACCEPT, "application/json")
|
|
|
|
.header(CONTENT_TYPE, "application/json")
|
|
|
|
.header(CONTENT_TYPE, "application/json")
|
|
|
|
.header(AUTHORIZATION, auth_header)
|
|
|
|
.header(AUTHORIZATION, &auth_header)
|
|
|
|
.json(&data)
|
|
|
|
.json(¬ification_data)
|
|
|
|
.send()
|
|
|
|
.send()
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
{
|
|
|
|
{
|
|
|
|