Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
seanaye/remove/unused notification code (#1242)
Sean Aye4d89f5131dfb
diff --git a/js/app/packages/service-clients/service-notification/generated/client.ts b/js/app/packages/service-clients/service-notification/generated/client.tsindex 49744190de..6bedddef2f 100644--- a/js/app/packages/service-clients/service-notification/generated/client.ts+++ b/js/app/packages/service-clients/service-notification/generated/client.ts@@ -969,98 +969,6 @@ export const getUserNotificationsByEventItemId = async (} as getUserNotificationsByEventItemIdResponse;};-/**- * @summary Marks the user's notification as done for a given event item id and type.- */-export type bulkMarkUserNotificationDoneByEventResponse200 = {- data: EmptyResponse;- status: 200;-};--export type bulkMarkUserNotificationDoneByEventResponseSuccess =- bulkMarkUserNotificationDoneByEventResponse200 & {- headers: Headers;- };--export type bulkMarkUserNotificationDoneByEventResponse =- bulkMarkUserNotificationDoneByEventResponseSuccess;--export const getBulkMarkUserNotificationDoneByEventUrl = (- eventItemId: string-) => {- return `/user_notifications/item/${eventItemId}/done`;-};--export const bulkMarkUserNotificationDoneByEvent = async (- eventItemId: string,- options?: RequestInit-): Promise<bulkMarkUserNotificationDoneByEventResponse> => {- const res = await fetch(- getBulkMarkUserNotificationDoneByEventUrl(eventItemId),- {- ...options,- method: 'PATCH',- }- );-- const body = [204, 205, 304].includes(res.status) ? null : await res.text();-- const data: bulkMarkUserNotificationDoneByEventResponse['data'] = body- ? JSON.parse(body)- : {};- return {- data,- status: res.status,- headers: res.headers,- } as bulkMarkUserNotificationDoneByEventResponse;-};--/**- * @summary Marks the user's notification as seen for a given event item id and type.- */-export type bulkMarkUserNotificationSeenByEventResponse200 = {- data: EmptyResponse;- status: 200;-};--export type bulkMarkUserNotificationSeenByEventResponseSuccess =- bulkMarkUserNotificationSeenByEventResponse200 & {- headers: Headers;- };--export type bulkMarkUserNotificationSeenByEventResponse =- bulkMarkUserNotificationSeenByEventResponseSuccess;--export const getBulkMarkUserNotificationSeenByEventUrl = (- eventItemId: string-) => {- return `/user_notifications/item/${eventItemId}/seen`;-};--export const bulkMarkUserNotificationSeenByEvent = async (- eventItemId: string,- options?: RequestInit-): Promise<bulkMarkUserNotificationSeenByEventResponse> => {- const res = await fetch(- getBulkMarkUserNotificationSeenByEventUrl(eventItemId),- {- ...options,- method: 'PATCH',- }- );-- const body = [204, 205, 304].includes(res.status) ? null : await res.text();-- const data: bulkMarkUserNotificationSeenByEventResponse['data'] = body- ? JSON.parse(body)- : {};- return {- data,- status: res.status,- headers: res.headers,- } as bulkMarkUserNotificationSeenByEventResponse;-};-/*** @summary Gets a single user notification by id.*/diff --git a/js/app/packages/service-clients/service-notification/openapi.json b/js/app/packages/service-clients/service-notification/openapi.jsonindex 35b4e4b53b..c9ce1043e1 100644--- a/js/app/packages/service-clients/service-notification/openapi.json+++ b/js/app/packages/service-clients/service-notification/openapi.json@@ -757,70 +757,6 @@}}},- "/user_notifications/item/{event_item_id}/done": {- "patch": {- "tags": [- "user_notification::bulk_mark_user_notification_done_by_event"- ],- "summary": "Marks the user's notification as done for a given event item id and type.",- "operationId": "bulk_mark_user_notification_done_by_event",- "parameters": [- {- "name": "event_item_id",- "in": "path",- "description": "ID of the event item",- "required": true,- "schema": {- "type": "string"- }- }- ],- "responses": {- "200": {- "description": "",- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/EmptyResponse"- }- }- }- }- }- }- },- "/user_notifications/item/{event_item_id}/seen": {- "patch": {- "tags": [- "user_notification::bulk_mark_user_notification_seen_by_event"- ],- "summary": "Marks the user's notification as seen for a given event item id and type.",- "operationId": "bulk_mark_user_notification_seen_by_event",- "parameters": [- {- "name": "event_item_id",- "in": "path",- "description": "ID of the event item",- "required": true,- "schema": {- "type": "string"- }- }- ],- "responses": {- "200": {- "description": "",- "content": {- "application/json": {- "schema": {- "$ref": "#/components/schemas/EmptyResponse"- }- }- }- }- }- }- },"/user_notifications/{notification_id}": {"get": {"tags": ["user_notification::get_user_notification_by_id"],diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/patch/done.rs b/rust/cloud-storage/notification_db_client/src/user_notification/patch/done.rsindex 08bb86e547..583f17f874 100644--- a/rust/cloud-storage/notification_db_client/src/user_notification/patch/done.rs+++ b/rust/cloud-storage/notification_db_client/src/user_notification/patch/done.rs@@ -1,5 +1,3 @@-use sqlx::types::Uuid;-/// mark the user's notification as done.#[tracing::instrument(skip(db))]pub async fn patch_done(@@ -47,32 +45,5 @@ pub async fn bulk_patch_done(Ok(())}-/// Marks the user's notification as done by event item id and type.-#[tracing::instrument(skip(db))]-pub async fn bulk_patch_done_by_event(- db: &sqlx::Pool<sqlx::Postgres>,- user_id: &str,- event_item_id: &str,-) -> anyhow::Result<Vec<Uuid>> {- let result = sqlx::query!(- r#"- DELETE FROM user_notification un- USING notification n- WHERE n.id = un.notification_id- AND n.event_item_id = $2- AND un.user_id = $1- AND un.done = false- RETURNING un.notification_id;- "#,- user_id,- event_item_id,- )- .map(|row| row.notification_id)- .fetch_all(db)- .await?;-- Ok(result)-}-#[cfg(test)]mod test;diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/patch/done/test.rs b/rust/cloud-storage/notification_db_client/src/user_notification/patch/done/test.rsindex 98d5d25f96..cb2d12eabe 100644--- a/rust/cloud-storage/notification_db_client/src/user_notification/patch/done/test.rs+++ b/rust/cloud-storage/notification_db_client/src/user_notification/patch/done/test.rs@@ -118,13 +118,3 @@ async fn test_bulk_patch_done(pool: Pool<Postgres>) -> anyhow::Result<()> {Ok(())}--#[sqlx::test(- migrator = "MACRO_DB_MIGRATIONS",- fixtures(path = "../../../../fixtures", scripts("user_notifications"))-)]-async fn test_bulk_patch_done_by_event(pool: Pool<Postgres>) -> anyhow::Result<()> {- bulk_patch_done_by_event(&pool, "macro|[email protected]", "test").await?;-- Ok(())-}diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen.rs b/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen.rsindex 473d1305cc..24c2dc1ac4 100644--- a/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen.rs+++ b/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen.rs@@ -1,5 +1,3 @@-use sqlx::types::Uuid;-/// mark the user's notification as seen.#[tracing::instrument(skip(db))]pub async fn patch_seen(@@ -44,33 +42,5 @@ pub async fn bulk_patch_seen(Ok(())}-/// Marks the user's notification as seen by event item id.-#[tracing::instrument(skip(db))]-pub async fn bulk_patch_seen_by_event(- db: &sqlx::Pool<sqlx::Postgres>,- user_id: &str,- event_item_id: &str,-) -> anyhow::Result<Vec<Uuid>> {- let result = sqlx::query!(- r#"- UPDATE user_notification un- SET seen_at = NOW()- FROM notification n- WHERE n.id = un.notification_id- AND n.event_item_id = $2- AND un.user_id = $1- AND un.seen_at IS NULL- RETURNING un.notification_id;- "#,- user_id,- event_item_id,- )- .map(|row| row.notification_id)- .fetch_all(db)- .await?;-- Ok(result)-}-#[cfg(test)]mod test;diff --git a/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen/test.rs b/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen/test.rsindex 3c307d5f7c..9c125de14e 100644--- a/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen/test.rs+++ b/rust/cloud-storage/notification_db_client/src/user_notification/patch/seen/test.rs@@ -81,13 +81,3 @@ async fn test_bulk_patch_seen(pool: Pool<Postgres>) -> anyhow::Result<()> {Ok(())}--#[sqlx::test(- migrator = "MACRO_DB_MIGRATIONS",- fixtures(path = "../../../../fixtures", scripts("user_notifications"))-)]-async fn test_bulk_patch_seen_by_event(pool: Pool<Postgres>) -> anyhow::Result<()> {- bulk_patch_seen_by_event(&pool, "macro|[email protected]", "test").await?;-- Ok(())-}diff --git a/rust/cloud-storage/notification_service/src/api/swagger.rs b/rust/cloud-storage/notification_service/src/api/swagger.rsindex aec4ddfea6..9d2702389f 100644--- a/rust/cloud-storage/notification_service/src/api/swagger.rs+++ b/rust/cloud-storage/notification_service/src/api/swagger.rs@@ -43,8 +43,6 @@ use crate::{user_notification::get_user_notification::handler,user_notification::get_user_notification_by_id::handler,user_notification::delete_user_notification::handler,- user_notification::bulk_mark_user_notification_seen_by_event::handler,- user_notification::bulk_mark_user_notification_done_by_event::handler,user_notification::bulk_delete_user_notification::handler,user_notification::bulk_mark_user_notification_seen::handler,user_notification::bulk_mark_user_notification_done::handler,diff --git a/rust/cloud-storage/notification_service/src/api/user_notification/bulk_mark_user_notification_done_by_event.rs b/rust/cloud-storage/notification_service/src/api/user_notification/bulk_mark_user_notification_done_by_event.rsdeleted file mode 100644index 87bce31df8..0000000000--- a/rust/cloud-storage/notification_service/src/api/user_notification/bulk_mark_user_notification_done_by_event.rs+++ /dev/null@@ -1,101 +0,0 @@-use std::borrow::Cow;--use axum::{- Extension, Json,- extract::{Path, State},- http::StatusCode,- response::{IntoResponse, Response},-};-use model::response::{EmptyResponse, ErrorResponse};--use crate::{api::context::ApiContext, notification};-use model::user::UserContext;--#[derive(serde::Deserialize)]-pub struct Params {- pub event_item_id: String,-}--/// Marks the user's notification as done for a given event item id and type.-#[utoipa::path(- patch,- operation_id = "bulk_mark_user_notification_done_by_event",- path = "/user_notifications/item/{event_item_id}/done",- params(- ("event_item_id" = String, Path, description = "ID of the event item")- ),- responses(- (status = 200, body=EmptyResponse),- )- )]-#[tracing::instrument(skip(ctx, user_context), fields(user_id=?user_context.user_id))]-pub async fn handler(- State(ctx): State<ApiContext>,- user_context: Extension<UserContext>,- Path(Params { event_item_id }): Path<Params>,-) -> Result<Response, Response> {- tracing::info!("bulk_mark_user_notification_done_by_event");-- let notification_ids =- notification_db_client::user_notification::patch::done::bulk_patch_done_by_event(- &ctx.db,- &user_context.user_id,- &event_item_id,- )- .await- .map_err(|e| {- tracing::error!(error=?e, "failed to patch user notification done for event");- (- StatusCode::INTERNAL_SERVER_ERROR,- Json(ErrorResponse {- message: "failed to patch user notification done for event",- }),- )- .into_response()- })?;-- if let Some(first_uuid) = notification_ids.first() {- // We only need the first notification as all basic info will be the same- let basic_notification_information =- notification_db_client::notification::get::get_basic_notification(&ctx.db, first_uuid)- .await- .map_err(|e| {- tracing::error!(error=?e, "failed to get basic notification information");- (- StatusCode::INTERNAL_SERVER_ERROR,- Json(ErrorResponse {- message: "failed to get basic notification information",- }),- )- .into_response()- })?;-- if basic_notification_information.event_item_type == "channel" {- tokio::spawn({- let db = ctx.db.clone();- let basic_notification_information = basic_notification_information.clone();- let user_id = user_context.user_id.clone();- async move {- if let Err(e) = notification_db_client::channel_notification_email_sent::delete::delete_channel_notification_email_sent(- &db,- &basic_notification_information.event_item_id,- &user_id,- )- .await {- tracing::error!(error=?e, basic_notification_information=?basic_notification_information, user_id=?user_id, "failed to delete channel notification email sent");- }- }- });- }-- tokio::spawn({- notification::send::push::remove::clear_push_notifications_basic(- ctx,- Cow::Owned(user_context.user_id.clone()),- basic_notification_information,- )- });- }-- Ok((StatusCode::OK, Json(EmptyResponse::default())).into_response())-}diff --git a/rust/cloud-storage/notification_service/src/api/user_notification/bulk_mark_user_notification_seen_by_event.rs b/rust/cloud-storage/notification_service/src/api/user_notification/bulk_mark_user_notification_seen_by_event.rsdeleted file mode 100644index 2ba6653e12..0000000000--- a/rust/cloud-storage/notification_service/src/api/user_notification/bulk_mark_user_notification_seen_by_event.rs+++ /dev/null@@ -1,101 +0,0 @@-use std::borrow::Cow;--use axum::{- Extension, Json,- extract::{Path, State},- http::StatusCode,- response::{IntoResponse, Response},-};-use model::response::{EmptyResponse, ErrorResponse};--use crate::{api::context::ApiContext, notification};-use model::user::UserContext;--#[derive(serde::Deserialize)]-pub struct Params {- pub event_item_id: String,-}--/// Marks the user's notification as seen for a given event item id and type.-#[utoipa::path(- patch,- operation_id = "bulk_mark_user_notification_seen_by_event",- path = "/user_notifications/item/{event_item_id}/seen",- params(- ("event_item_id" = String, Path, description = "ID of the event item")- ),- responses(- (status = 200, body=EmptyResponse),- )- )]-#[tracing::instrument(skip(ctx, user_context), fields(user_id=?user_context.user_id))]-pub async fn handler(- State(ctx): State<ApiContext>,- user_context: Extension<UserContext>,- Path(Params { event_item_id }): Path<Params>,-) -> Result<Response, Response> {- tracing::info!("bulk_mark_user_notification_seen_by_event");-- let notification_ids =- notification_db_client::user_notification::patch::seen::bulk_patch_seen_by_event(- &ctx.db,- &user_context.user_id,- &event_item_id,- )- .await- .map_err(|e| {- tracing::error!(error=?e, "failed to patch user notification seen for event");- (- StatusCode::INTERNAL_SERVER_ERROR,- Json(ErrorResponse {- message: "failed to patch user notification seen for event",- }),- )- .into_response()- })?;-- if let Some(first_uuid) = notification_ids.first() {- // We only need the first notification as all basic info will be the same- let basic_notification_information =- notification_db_client::notification::get::get_basic_notification(&ctx.db, first_uuid)- .await- .map_err(|e| {- tracing::error!(error=?e, "failed to get basic notification information");- (- StatusCode::INTERNAL_SERVER_ERROR,- Json(ErrorResponse {- message: "failed to get basic notification information",- }),- )- .into_response()- })?;-- if basic_notification_information.event_item_type == "channel" {- tokio::spawn({- let db = ctx.db.clone();- let basic_notification_information = basic_notification_information.clone();- let user_id = user_context.user_id.clone();- async move {- if let Err(e) = notification_db_client::channel_notification_email_sent::delete::delete_channel_notification_email_sent(- &db,- &basic_notification_information.event_item_id,- &user_id,- )- .await {- tracing::error!(error=?e, basic_notification_information=?basic_notification_information, user_id=?user_id, "failed to delete channel notification email sent");- }- }- });- }-- tokio::spawn({- notification::send::push::remove::clear_push_notifications_basic(- ctx,- Cow::Owned(user_context.user_id.clone()),- basic_notification_information,- )- });- }-- Ok((StatusCode::OK, Json(EmptyResponse::default())).into_response())-}diff --git a/rust/cloud-storage/notification_service/src/api/user_notification/mod.rs b/rust/cloud-storage/notification_service/src/api/user_notification/mod.rsindex 3937cbb05a..a821fe0986 100644--- a/rust/cloud-storage/notification_service/src/api/user_notification/mod.rs+++ b/rust/cloud-storage/notification_service/src/api/user_notification/mod.rs@@ -7,9 +7,7 @@ use axum::{pub(in crate::api) mod bulk_delete_user_notification;pub(in crate::api) mod bulk_get_user_notifications_by_event_item_id;pub(in crate::api) mod bulk_mark_user_notification_done;-pub(in crate::api) mod bulk_mark_user_notification_done_by_event;pub(in crate::api) mod bulk_mark_user_notification_seen;-pub(in crate::api) mod bulk_mark_user_notification_seen_by_event;pub(in crate::api) mod bulk_mark_user_notification_undone;pub(in crate::api) mod delete_user_notification;pub(in crate::api) mod get_user_notification;@@ -44,12 +42,4 @@ pub fn router() -> Router<ApiContext> {"/bulk/undone",patch(bulk_mark_user_notification_undone::handler),)- .route(- "/item/:event_item_id/seen",- patch(bulk_mark_user_notification_seen_by_event::handler),- )- .route(- "/item/:event_item_id/done",- patch(bulk_mark_user_notification_done_by_event::handler),- )}diff --git a/rust/cloud-storage/notification_service/src/notification/send/push/remove.rs b/rust/cloud-storage/notification_service/src/notification/send/push/remove.rsindex f9460af36a..cf57193e01 100644--- a/rust/cloud-storage/notification_service/src/notification/send/push/remove.rs+++ b/rust/cloud-storage/notification_service/src/notification/send/push/remove.rs@@ -4,7 +4,6 @@ use futures::StreamExt;use notification_db_client::notification::get::DbBasicNotification;use serde::Serialize;use sns_client::{APNSPushNotification, MessageAttributes, PushType, SnsTarget};-use std::borrow::Cow;/// Clears out push notifications for a user in bulk#[tracing::instrument(skip(ctx))]@@ -113,38 +112,3 @@ pub async fn clear_push_notification(Ok(())}--/// Clears out push notifications for a user by notification event-#[tracing::instrument(err, skip(ctx))]-pub async fn clear_push_notifications_basic(- ctx: ApiContext,- user_id: Cow<'_, str>,- notification: DbBasicNotification<Option<String>>,-) -> anyhow::Result<()> {- tracing::trace!("clearing potential push notifications");- let db = ctx.db.clone();- let sns_client = ctx.sns_client.clone();- let user_id = user_id.to_string();- tracing::trace!("removing push notifications");-- let device_endpoints = notification_db_client::device::get_user_device_endpoints(&db, &user_id)- .await- .inspect_err(|e| {- tracing::error!(error=?e, "failed to get device endpoints");- })- .unwrap_or(Vec::new());-- if device_endpoints.is_empty() {- tracing::trace!("user has no device endpoints, skipping push notification clearing");- return Ok(());- }-- let Some(basic_notification) = notification.transpose() else {- tracing::trace!("cannot clear a notification that is missing a collapse key");- return Ok(());- };-- let _ = clear_push_notification(&sns_client, &device_endpoints, basic_notification).await;-- Ok(())-}