Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Remove obsolete wall notifications endpoint

Anand Baburajan05c93b5a27f6
diff --git a/rust/e2e/Cargo.lock b/rust/e2e/Cargo.lock
index ff6decd84a..3bbe42cd8c 100644
--- a/rust/e2e/Cargo.lock
+++ b/rust/e2e/Cargo.lock
@@ -725,6 +725,7 @@ dependencies = [
"base64",
"ente-core",
"serde",
+ "serde_json",
"thiserror 2.0.18",
"url",
"urlencoding",
diff --git a/rust/e2e/tests/wall_e2e.rs b/rust/e2e/tests/wall_e2e.rs
index 507b843357..fdd7f7c147 100644
--- a/rust/e2e/tests/wall_e2e.rs
+++ b/rust/e2e/tests/wall_e2e.rs
@@ -2,7 +2,7 @@ mod support;
#[path = "support/wall.rs"]
mod wall;
-use ente_wall::{OpenWallLinkCtxInput, WallLinkCtx, WallNotificationType};
+use ente_wall::{OpenWallLinkCtxInput, WallLinkCtx};
use support::auth;
@@ -224,26 +224,6 @@ async fn wall_bootstrap_posts_friend_share_and_link_suite() {
Some(friend_profile_payload.as_slice())
);
- let notifications = owner_ctx
- .list_notifications(None, Some(10))
- .await
- .expect("owner notifications should load");
- let liked_notification = notifications
- .items
- .iter()
- .find(|item| item.notification_type == WallNotificationType::LikedPost)
- .expect("liked post notification should exist");
- assert_eq!(liked_notification.actor.wall_id, friend_wall.wall_id);
- assert_eq!(
- liked_notification
- .post
- .as_ref()
- .expect("liked post notification should include post")
- .author
- .wall_id,
- owner_wall.wall_id
- );
-
wall::assert_http_status(outsider_ctx.fetch_post_decrypted(post_id).await, 403);
let link_profile = link_ctx
diff --git a/rust/wall/src/client.rs b/rust/wall/src/client.rs
index 2c015bc173..ae9c9c2c41 100644
--- a/rust/wall/src/client.rs
+++ b/rust/wall/src/client.rs
@@ -23,7 +23,7 @@ use crate::transport::{
UpdatePostCaptionRequest, UpdateWallProfileRequest, UpdateWallProfileResponse,
UpdateWallSlugRequest, WallActorResponse, WallFriendResponse, WallKeyResponse,
WallKeyVersionResponse, WallLinkCreateRequest, WallLinkLoginRequest, WallLinkLoginResponse,
- WallLinkStatusResponse, WallLookupResponse, WallNotificationPage, WallProfileResponse,
+ WallLinkStatusResponse, WallLookupResponse, WallProfileResponse,
};
use ente_core::crypto::{sealed, secretbox};
use ente_core::http::{Error as HttpError, HttpClient, HttpConfig};
@@ -624,24 +624,6 @@ impl AccountWallCtx {
.map_err(Into::into)
}
- pub async fn list_notifications(
- &self,
- cursor: Option<String>,
- limit: Option<i32>,
- ) -> Result<WallNotificationPage> {
- let mut query = Vec::new();
- if let Some(value) = cursor.filter(|value| !value.trim().is_empty()) {
- query.push(("cursor", value));
- }
- if let Some(value) = limit {
- query.push(("limit", value.to_string()));
- }
- self.client
- .get_json("/wall/notifications", &query)
- .await
- .map_err(Into::into)
- }
-
pub async fn get_post(&self, post_id: i64) -> Result<PostResponse> {
let path = format!("/wall/posts/{post_id}");
self.client.get_json(&path, &[]).await.map_err(Into::into)
@@ -2965,104 +2947,6 @@ mod tests {
feed.assert_async().await;
}
- #[tokio::test]
- async fn list_notifications_uses_wall_notifications_endpoint() {
- let mut server = Server::new_async().await;
- let ctx = test_account_ctx(&server.url());
- let notifications = server
- .mock("GET", "/wall/notifications")
- .match_header("x-auth-token", "token")
- .match_query(Matcher::AllOf(vec![
- Matcher::UrlEncoded("cursor".into(), "cursor-1".into()),
- Matcher::UrlEncoded("limit".into(), "5".into()),
- ]))
- .with_status(200)
- .with_body(
- json!({
- "items": [
- {
- "id": "post_like:42:9",
- "type": "likedPost",
- "createdAt": "2026-04-16T00:00:00Z",
- "actor": {
- "userId": 9,
- "username": "mira",
- "wallId": "wall_mira",
- "wallSlug": "mira"
- },
- "post": {
- "postId": 42,
- "wallId": "wall_owner_gallery",
- "wallSlug": "owner-gallery",
- "ownerUserId": 7,
- "author": {
- "userId": 7,
- "wallId": "wall_owner_gallery",
- "wallSlug": "owner-gallery"
- }
- }
- },
- {
- "id": "post_reply:wmsg_1",
- "type": "repliedToPost",
- "createdAt": "2026-04-16T12:00:00Z",
- "actor": {
- "userId": 9,
- "username": "mira",
- "wallId": "wall_mira",
- "wallSlug": "mira"
- },
- "post": {
- "postId": 42,
- "wallId": "wall_owner_gallery",
- "wallSlug": "owner-gallery",
- "ownerUserId": 7,
- "author": {
- "userId": 7,
- "wallId": "wall_owner_gallery",
- "wallSlug": "owner-gallery"
- }
- }
- },
- {
- "id": "friend_remove:12",
- "type": "removedYouAsFriend",
- "createdAt": "2026-04-17T00:00:00Z",
- "actor": {
- "wallSlug": "mira"
- }
- }
- ],
- "nextCursor": "cursor-2"
- })
- .to_string(),
- )
- .create_async()
- .await;
-
- let page = ctx
- .list_notifications(Some("cursor-1".to_owned()), Some(5))
- .await
- .expect("notifications should load");
-
- assert_eq!(page.items.len(), 3);
- assert_eq!(
- page.items[0].notification_type,
- crate::transport::WallNotificationType::LikedPost
- );
- assert_eq!(
- page.items[1].notification_type,
- crate::transport::WallNotificationType::RepliedToPost
- );
- assert_eq!(
- page.items[2].notification_type,
- crate::transport::WallNotificationType::RemovedYouAsFriend
- );
- assert_eq!(page.items[0].actor.wall_slug, "mira");
- assert_eq!(page.next_cursor, "cursor-2");
- notifications.assert_async().await;
- }
-
#[tokio::test]
async fn list_posts_uses_wall_posts_page_endpoint() {
let mut server = Server::new_async().await;
diff --git a/rust/wall/src/lib.rs b/rust/wall/src/lib.rs
index 86f10fc89e..4b3cafcbb0 100644
--- a/rust/wall/src/lib.rs
+++ b/rust/wall/src/lib.rs
@@ -18,6 +18,5 @@ pub use transport::{
MessageResponse, PostLikerResponse, PostObjectPayload, PostPage, PostResponse,
PresignUploadResponse, ProfileAvatarPayload, ProfileAvatarResponse, WallActorResponse,
WallFriendResponse, WallKeyResponse, WallKeyVersionResponse, WallLinkLoginResponse,
- WallLinkStatusResponse, WallLookupResponse, WallNotification, WallNotificationPage,
- WallNotificationPost, WallNotificationType, WallProfileResponse,
+ WallLinkStatusResponse, WallLookupResponse, WallProfileResponse,
};
diff --git a/rust/wall/src/transport.rs b/rust/wall/src/transport.rs
index 86a5f425ab..7d2a7549dd 100644
--- a/rust/wall/src/transport.rs
+++ b/rust/wall/src/transport.rs
@@ -259,15 +259,6 @@ pub struct PostPage {
pub next_cursor: String,
}
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
-#[serde(rename_all = "camelCase")]
-pub enum WallNotificationType {
- LikedPost,
- RepliedToPost,
- AddedYouAsFriend,
- RemovedYouAsFriend,
-}
-
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct WallActorResponse {
@@ -290,38 +281,6 @@ pub struct WallActorResponse {
pub posts: Option<i64>,
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct WallNotificationPost {
- pub post_id: i64,
- pub wall_id: String,
- pub wall_slug: String,
- pub owner_user_id: i64,
- pub author: WallActorResponse,
- #[serde(default)]
- pub objects: Vec<PostObjectPayload>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct WallNotification {
- pub id: String,
- #[serde(rename = "type")]
- pub notification_type: WallNotificationType,
- pub created_at: String,
- pub actor: WallActorResponse,
- #[serde(default)]
- pub post: Option<WallNotificationPost>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct WallNotificationPage {
- pub items: Vec<WallNotification>,
- #[serde(default)]
- pub next_cursor: String,
-}
-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ProfileAvatarPayload {
diff --git a/server/wall/api/notifications.go b/server/wall/api/notifications.go
deleted file mode 100644
index ee4f1d02b8..0000000000
--- a/server/wall/api/notifications.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package api
-
-import (
- "github.com/ente-io/museum/ente"
- "github.com/ente-io/museum/wall/models"
- "github.com/gin-gonic/gin"
-)
-
-func (h *Handlers) ListNotifications(c *gin.Context) {
- var req models.ListNotificationsRequest
- if err := c.ShouldBindQuery(&req); err != nil {
- respondJSON(c, nil, ente.ErrBadRequest)
- return
- }
- resp, err := h.Module.Notifications.List(c, req)
- respondJSON(c, resp, err)
-}
diff --git a/server/wall/api/register.go b/server/wall/api/register.go
index bc6e0effea..94dc166f34 100644
--- a/server/wall/api/register.go
+++ b/server/wall/api/register.go
@@ -21,7 +21,6 @@ func Register(privateAPI, publicAPI gin.IRoutes, handlers *Handlers) {
privateAPI.POST("/wall/messages/:wallID", handlers.CreateMessage)
privateAPI.POST("/wall/message/:messageID/like", handlers.ToggleMessageLike)
privateAPI.DELETE("/wall/message/:messageID", handlers.DeleteMessage)
- privateAPI.GET("/wall/notifications", handlers.ListNotifications)
privateAPI.POST("/wall/friends/add", handlers.AddFriend)
privateAPI.POST("/wall/friends/unfriend", handlers.Unfriend)
privateAPI.GET("/wall/friends", handlers.ListWallFriends)
diff --git a/server/wall/controller/module.go b/server/wall/controller/module.go
index 89e37f4c5b..7a654863c9 100644
--- a/server/wall/controller/module.go
+++ b/server/wall/controller/module.go
@@ -6,15 +6,14 @@ import (
)
type Module struct {
- Walls *WallsController
- Posts *PostsController
- Friends *FriendsController
- Messages *MessagesController
- Notifications *NotificationsController
- Links *LinksController
- Assets *AssetsController
- Cleanup *CleanupController
- UserAuth *baserepo.UserAuthRepository
+ Walls *WallsController
+ Posts *PostsController
+ Friends *FriendsController
+ Messages *MessagesController
+ Links *LinksController
+ Assets *AssetsController
+ Cleanup *CleanupController
+ UserAuth *baserepo.UserAuthRepository
}
func NewModule(repos *repo.Module, userAuthRepo *baserepo.UserAuthRepository) *Module {
@@ -25,14 +24,13 @@ func NewModule(repos *repo.Module, userAuthRepo *baserepo.UserAuthRepository) *M
FriendsRepo: repos.Friends,
}
return &Module{
- Walls: &WallsController{WallsRepo: repos.Walls, AssetsRepo: repos.Assets, auth: authDeps},
- Posts: &PostsController{PostsRepo: repos.Posts, WallsRepo: repos.Walls, AssetsRepo: repos.Assets, auth: authDeps},
- Friends: &FriendsController{FriendsRepo: repos.Friends, WallsRepo: repos.Walls, auth: authDeps},
- Messages: &MessagesController{MessagesRepo: repos.Messages, PostsRepo: repos.Posts, WallsRepo: repos.Walls, FriendsRepo: repos.Friends, auth: authDeps},
- Notifications: &NotificationsController{NotificationsRepo: repos.Notifications, auth: authDeps},
- Links: &LinksController{LinksRepo: repos.Links, WallsRepo: repos.Walls, auth: authDeps},
- Assets: &AssetsController{AssetsRepo: repos.Assets, WallsRepo: repos.Walls, LinksRepo: repos.Links, auth: authDeps},
- Cleanup: &CleanupController{AssetsRepo: repos.Assets},
- UserAuth: userAuthRepo,
+ Walls: &WallsController{WallsRepo: repos.Walls, AssetsRepo: repos.Assets, auth: authDeps},
+ Posts: &PostsController{PostsRepo: repos.Posts, WallsRepo: repos.Walls, AssetsRepo: repos.Assets, auth: authDeps},
+ Friends: &FriendsController{FriendsRepo: repos.Friends, WallsRepo: repos.Walls, auth: authDeps},
+ Messages: &MessagesController{MessagesRepo: repos.Messages, PostsRepo: repos.Posts, WallsRepo: repos.Walls, FriendsRepo: repos.Friends, auth: authDeps},
+ Links: &LinksController{LinksRepo: repos.Links, WallsRepo: repos.Walls, auth: authDeps},
+ Assets: &AssetsController{AssetsRepo: repos.Assets, WallsRepo: repos.Walls, LinksRepo: repos.Links, auth: authDeps},
+ Cleanup: &CleanupController{AssetsRepo: repos.Assets},
+ UserAuth: userAuthRepo,
}
}
diff --git a/server/wall/controller/notifications.go b/server/wall/controller/notifications.go
deleted file mode 100644
index a0bc123033..0000000000
--- a/server/wall/controller/notifications.go
+++ /dev/null
@@ -1,86 +0,0 @@
-package controller
-
-import (
- "github.com/ente-io/museum/wall/models"
- "github.com/ente-io/museum/wall/repo"
- "github.com/gin-gonic/gin"
-)
-
-type NotificationsController struct {
- NotificationsRepo *repo.NotificationsRepository
- auth authDeps
-}
-
-func (c *NotificationsController) List(ctx *gin.Context, req models.ListNotificationsRequest) (*models.NotificationPage, error) {
- userID, err := c.auth.requireUser(ctx)
- if err != nil {
- return nil, err
- }
- notifications, nextCursor, err := c.NotificationsRepo.List(ctx.Request.Context(), userID, req.Cursor, req.Limit)
- if err != nil {
- return nil, err
- }
- actors := make([]repo.WallActorRecord, 0, len(notifications)*3)
- for _, notification := range notifications {
- actors = append(actors, notification.Actor)
- if notification.PostID.Valid {
- actors = append(actors, notification.PostAuthor)
- }
- }
- visible, err := actorVisibility(ctx.Request.Context(), c.auth, &viewerAuth{UserID: userID}, actors...)
- if err != nil {
- return nil, err
- }
- items := make([]models.NotificationResponse, 0, len(notifications))
- for _, notification := range notifications {
- items = append(items, toNotificationResponse(notification, visible))
- }
- return &models.NotificationPage{Items: items, NextCursor: nextCursor}, nil
-}
-
-func toNotificationResponse(notification repo.WallNotificationRecord, visible map[string]bool) models.NotificationResponse {
- resp := models.NotificationResponse{
- ID: notification.ID,
- Type: notification.Type,
- CreatedAt: formatMicros(notification.CreatedAt),
- Actor: toActorResponse(notification.Actor, visibleActor(visible, notification.Actor)),
- }
- if notification.PostID.Valid {
- post := &models.NotificationPostResponse{
- PostID: notification.PostID.Int64,
- WallID: notification.PostWallID.String,
- WallSlug: notification.PostWallSlug.String,
- OwnerUserID: notification.PostOwnerID.Int64,
- Author: toActorResponse(notification.PostAuthor, visibleActor(visible, notification.PostAuthor)),
- }
- if notification.PostObjectKey.Valid {
- object := models.PostObjectPayload{
- ObjectKey: notification.PostObjectKey.String,
- }
- if notification.PostObjectSize.Valid {
- object.Size = notification.PostObjectSize.Int64
- }
- if notification.PostObjectPosition.Valid {
- object.Position = int(notification.PostObjectPosition.Int64)
- }
- if notification.PostObjectVariant.Valid {
- object.Variant = notification.PostObjectVariant.String
- }
- if notification.PostObjectBlurHashCipher.Valid {
- object.BlurHashCipher = notification.PostObjectBlurHashCipher.String
- }
- if notification.PostObjectWidth.Valid {
- object.Width = int(notification.PostObjectWidth.Int64)
- }
- if notification.PostObjectHeight.Valid {
- object.Height = int(notification.PostObjectHeight.Int64)
- }
- if notification.PostObjectMediaType.Valid {
- object.MediaType = notification.PostObjectMediaType.String
- }
- post.Objects = []models.PostObjectPayload{object}
- }
- resp.Post = post
- }
- return resp
-}
diff --git a/server/wall/models/models.go b/server/wall/models/models.go
index 310be92026..51bfd8dcc5 100644
--- a/server/wall/models/models.go
+++ b/server/wall/models/models.go
@@ -26,11 +26,6 @@ type ListFeedRequest struct {
Limit int `form:"limit"`
}
-type ListNotificationsRequest struct {
- Cursor string `form:"cursor"`
- Limit int `form:"limit"`
-}
-
type ListMessagesRequest struct {
Cursor string `form:"cursor"`
Limit int `form:"limit"`
@@ -367,28 +362,6 @@ type FeedPage struct {
NextCursor string `json:"nextCursor,omitempty"`
}
-type NotificationPostResponse struct {
- PostID int64 `json:"postId"`
- WallID string `json:"wallId"`
- WallSlug string `json:"wallSlug"`
- OwnerUserID int64 `json:"ownerUserId"`
- Author WallActorResponse `json:"author"`
- Objects []PostObjectPayload `json:"objects,omitempty"`
-}
-
-type NotificationResponse struct {
- ID string `json:"id"`
- Type string `json:"type"`
- CreatedAt string `json:"createdAt"`
- Actor WallActorResponse `json:"actor"`
- Post *NotificationPostResponse `json:"post,omitempty"`
-}
-
-type NotificationPage struct {
- Items []NotificationResponse `json:"items"`
- NextCursor string `json:"nextCursor,omitempty"`
-}
-
type UpdatedCountResponse struct {
Updated int `json:"updated"`
}
diff --git a/server/wall/repo/module.go b/server/wall/repo/module.go
index f776bf3aca..451d35e848 100644
--- a/server/wall/repo/module.go
+++ b/server/wall/repo/module.go
@@ -7,13 +7,12 @@ import (
)
type Module struct {
- Walls *WallsRepository
- Posts *PostsRepository
- Friends *FriendsRepository
- Messages *MessagesRepository
- Notifications *NotificationsRepository
- Links *LinksRepository
- Assets *AssetsRepository
+ Walls *WallsRepository
+ Posts *PostsRepository
+ Friends *FriendsRepository
+ Messages *MessagesRepository
+ Links *LinksRepository
+ Assets *AssetsRepository
}
type WallsRepository struct {
@@ -32,10 +31,6 @@ type MessagesRepository struct {
DB *sql.DB
}
-type NotificationsRepository struct {
- DB *sql.DB
-}
-
type LinksRepository struct {
DB *sql.DB
}
@@ -237,34 +232,13 @@ type WallLinkSessionRecord struct {
EncryptedWallKey string
}
-type WallNotificationRecord struct {
- ID string
- Type string
- CreatedAt int64
- Actor WallActorRecord
- PostID sql.NullInt64
- PostWallID sql.NullString
- PostWallSlug sql.NullString
- PostOwnerID sql.NullInt64
- PostAuthor WallActorRecord
- PostObjectKey sql.NullString
- PostObjectSize sql.NullInt64
- PostObjectPosition sql.NullInt64
- PostObjectVariant sql.NullString
- PostObjectBlurHashCipher sql.NullString
- PostObjectWidth sql.NullInt64
- PostObjectHeight sql.NullInt64
- PostObjectMediaType sql.NullString
-}
-
func NewModule(db *sql.DB, s3Config *s3config.S3Config) *Module {
return &Module{
- Walls: &WallsRepository{DB: db},
- Posts: &PostsRepository{DB: db},
- Friends: &FriendsRepository{DB: db},
- Messages: &MessagesRepository{DB: db},
- Notifications: &NotificationsRepository{DB: db},
- Links: &LinksRepository{DB: db},
- Assets: &AssetsRepository{DB: db, S3Config: s3Config},
+ Walls: &WallsRepository{DB: db},
+ Posts: &PostsRepository{DB: db},
+ Friends: &FriendsRepository{DB: db},
+ Messages: &MessagesRepository{DB: db},
+ Links: &LinksRepository{DB: db},
+ Assets: &AssetsRepository{DB: db, S3Config: s3Config},
}
}
diff --git a/server/wall/repo/module_test.go b/server/wall/repo/module_test.go
index bb38d9bb9f..ca90910fd1 100644
--- a/server/wall/repo/module_test.go
+++ b/server/wall/repo/module_test.go
@@ -1041,63 +1041,6 @@ func TestListFeedCursorUsesCreatedAtSortOrder(t *testing.T) {
require.Empty(t, nextCursor)
}
-func TestNotificationsIncludeWallSocialEvents(t *testing.T) {
- ctx := context.Background()
- module := newWallTestModule(t)
-
- aliceID := insertWallUser(t, module, "[email protected]", "alice-public")
- bobID := insertWallUser(t, module, "[email protected]", "bob-public")
- aliceWall, err := module.Walls.CreateWall(ctx, aliceID, "alice", "alice-wall-key", "alice-profile")
- require.NoError(t, err)
- bobWall, err := module.Walls.CreateWall(ctx, bobID, "bob", "bob-wall-key", "bob-profile")
- require.NoError(t, err)
-
- postID, err := module.Posts.CreatePost(ctx, aliceID, aliceWall.WallID, "post-key", nil, aliceWall.CurrentVersion, nil)
- require.NoError(t, err)
- err = module.Posts.SetLike(ctx, postID, bobID, true)
- require.NoError(t, err)
- setPostLikeCreatedAt(t, module, 2000, postID, bobID)
-
- err = module.Friends.AddFriend(ctx, bobID, bobWall.WallID, aliceWall.WallID, "alice-share-key", aliceWall.CurrentVersion, "bob-share-key", bobWall.CurrentVersion)
- require.NoError(t, err)
- setFriendEventCreatedAt(t, module, 3000, "friend_add", bobID, aliceID)
-
- reply, err := module.Messages.CreateMessage(ctx, CreateWallMessageRecord{
- Kind: "post_reply",
- SenderID: bobID,
- SenderWallID: bobWall.WallID,
- RecipientID: aliceID,
- RecipientWallID: aliceWall.WallID,
- MessageCipher: "reply-cipher",
- SenderEncryptedMessageKey: "sender-reply-key",
- RecipientEncryptedMessageKey: "recipient-reply-key",
- ReplyPostID: sql.NullInt64{Int64: postID, Valid: true},
- })
- require.NoError(t, err)
- setMessageCreatedAt(t, module, 3500, reply.MessageID)
-
- page, nextCursor, err := module.Notifications.List(ctx, aliceID, "", 5)
- require.NoError(t, err)
- require.Len(t, page, 3)
- require.Equal(t, "repliedToPost", page[0].Type)
- require.Equal(t, bobID, page[0].Actor.UserID)
- require.Equal(t, postID, page[0].PostID.Int64)
- require.Equal(t, "addedYouAsFriend", page[1].Type)
- require.Equal(t, "likedPost", page[2].Type)
- require.Empty(t, nextCursor)
-
- err = module.Friends.DeleteFriendship(ctx, aliceID, bobWall.WallID)
- require.NoError(t, err)
- setFriendEventCreatedAt(t, module, 4000, "friend_remove", aliceID, bobID)
-
- page, nextCursor, err = module.Notifications.List(ctx, bobID, "", 3)
- require.NoError(t, err)
- require.Len(t, page, 1)
- require.Equal(t, "removedYouAsFriend", page[0].Type)
- require.Equal(t, aliceID, page[0].Actor.UserID)
- require.Empty(t, nextCursor)
-}
-
func TestListPostLikersPaginates(t *testing.T) {
ctx := context.Background()
module := newWallTestModule(t)
diff --git a/server/wall/repo/notifications.go b/server/wall/repo/notifications.go
deleted file mode 100644
index e9cefc6baa..0000000000
--- a/server/wall/repo/notifications.go
+++ /dev/null
@@ -1,213 +0,0 @@
-package repo
-
-import (
- "context"
- "strconv"
- "strings"
-
- "github.com/ente-io/stacktrace"
-)
-
-const wallNotificationRows = `
- SELECT
- 'post_like:' || pl.post_id::text || ':' || pl.user_id::text AS notification_id,
- 'likedPost' AS notification_type,
- pl.created_at,
- actor_wall.owner_id, actor_wall.wall_id, actor_wall.wall_slug, actor_ka.public_key,
- actor_wall.current_version, actor_wall.encrypted_profile, actor_wall.avatar_object_key,
- actor_wall.avatar_size, actor_wall.updated_at,
- (SELECT COUNT(*) FROM wall_friend_shares fs WHERE fs.wall_id = actor_wall.wall_id) AS actor_friends,
- (SELECT COUNT(*) FROM wall_posts ap WHERE ap.wall_id = actor_wall.wall_id AND ap.is_deleted = FALSE) AS actor_posts,
- p.post_id,
- p.wall_id AS post_wall_id,
- post_wall.wall_slug AS post_wall_slug,
- p.owner_id AS post_owner_id,
- owner_wall.owner_id, owner_wall.wall_id, owner_wall.wall_slug, owner_ka.public_key,
- owner_wall.current_version, owner_wall.encrypted_profile, owner_wall.avatar_object_key,
- owner_wall.avatar_size, owner_wall.updated_at,
- (SELECT COUNT(*) FROM wall_friend_shares fs WHERE fs.wall_id = owner_wall.wall_id) AS post_author_friends,
- (SELECT COUNT(*) FROM wall_posts op WHERE op.wall_id = owner_wall.wall_id AND op.is_deleted = FALSE) AS post_author_posts,
- asset.object_key AS post_object_key,
- asset.size AS post_object_size,
- asset.position AS post_object_position,
- asset.variant AS post_object_variant,
- asset.blur_hash_cipher AS post_object_blur_hash_cipher,
- asset.width AS post_object_width,
- asset.height AS post_object_height,
- asset.media_type AS post_object_media_type
- FROM wall_post_likes pl
- JOIN wall_posts p ON p.post_id = pl.post_id
- JOIN walls actor_wall ON actor_wall.owner_id = pl.user_id
- JOIN key_attributes actor_ka ON actor_ka.user_id = pl.user_id
- JOIN walls post_wall ON post_wall.wall_id = p.wall_id
- JOIN walls owner_wall ON owner_wall.wall_id = p.wall_id
- JOIN key_attributes owner_ka ON owner_ka.user_id = p.owner_id
- LEFT JOIN LATERAL (
- SELECT object_key, size, position, variant, blur_hash_cipher, width, height, media_type
- FROM wall_post_assets
- WHERE post_id = p.post_id
- ORDER BY position ASC, asset_id ASC
- LIMIT 1
- ) asset ON TRUE
- WHERE p.owner_id = $1
- AND pl.user_id <> $1
- AND p.is_deleted = FALSE
-
- UNION ALL
-
- SELECT
- CASE fe.event_type
- WHEN 'friend_remove' THEN 'friend_remove:'
- ELSE 'friend_add:'
- END || fe.event_id::text AS notification_id,
- CASE fe.event_type
- WHEN 'friend_remove' THEN 'removedYouAsFriend'
- ELSE 'addedYouAsFriend'
- END AS notification_type,
- fe.created_at,
- actor_wall.owner_id, actor_wall.wall_id, actor_wall.wall_slug, actor_ka.public_key,
- actor_wall.current_version, actor_wall.encrypted_profile, actor_wall.avatar_object_key,
- actor_wall.avatar_size, actor_wall.updated_at,
- (SELECT COUNT(*) FROM wall_friend_shares fs WHERE fs.wall_id = actor_wall.wall_id) AS actor_friends,
- (SELECT COUNT(*) FROM wall_posts ap WHERE ap.wall_id = actor_wall.wall_id AND ap.is_deleted = FALSE) AS actor_posts,
- NULL::bigint AS post_id,
- NULL::text AS post_wall_id,
- NULL::text AS post_wall_slug,
- NULL::bigint AS post_owner_id,
- 0::bigint, ''::text, ''::text, ''::text, 0::integer, ''::text, NULL::text, NULL::bigint, 0::bigint, NULL::bigint, NULL::bigint,
- NULL::text AS post_object_key,
- NULL::bigint AS post_object_size,
- NULL::integer AS post_object_position,
- NULL::text AS post_object_variant,
- NULL::text AS post_object_blur_hash_cipher,
- NULL::integer AS post_object_width,
- NULL::integer AS post_object_height,
- NULL::text AS post_object_media_type
- FROM wall_friend_events fe
- JOIN walls actor_wall ON actor_wall.wall_id = fe.actor_wall_id
- JOIN key_attributes actor_ka ON actor_ka.user_id = actor_wall.owner_id
- WHERE fe.target_id = $1
- AND fe.actor_id <> $1
-
- UNION ALL
-
- SELECT
- 'post_reply:' || m.message_id AS notification_id,
- 'repliedToPost' AS notification_type,
- m.created_at,
- actor_wall.owner_id, actor_wall.wall_id, actor_wall.wall_slug, actor_ka.public_key,
- actor_wall.current_version, actor_wall.encrypted_profile, actor_wall.avatar_object_key,
- actor_wall.avatar_size, actor_wall.updated_at,
- (SELECT COUNT(*) FROM wall_friend_shares fs WHERE fs.wall_id = actor_wall.wall_id) AS actor_friends,
- (SELECT COUNT(*) FROM wall_posts ap WHERE ap.wall_id = actor_wall.wall_id AND ap.is_deleted = FALSE) AS actor_posts,
- p.post_id,
- p.wall_id AS post_wall_id,
- post_wall.wall_slug AS post_wall_slug,
- p.owner_id AS post_owner_id,
- owner_wall.owner_id, owner_wall.wall_id, owner_wall.wall_slug, owner_ka.public_key,
- owner_wall.current_version, owner_wall.encrypted_profile, owner_wall.avatar_object_key,
- owner_wall.avatar_size, owner_wall.updated_at,
- (SELECT COUNT(*) FROM wall_friend_shares fs WHERE fs.wall_id = owner_wall.wall_id) AS post_author_friends,
- (SELECT COUNT(*) FROM wall_posts op WHERE op.wall_id = owner_wall.wall_id AND op.is_deleted = FALSE) AS post_author_posts,
- asset.object_key AS post_object_key,
- asset.size AS post_object_size,
- asset.position AS post_object_position,
- asset.variant AS post_object_variant,
- asset.blur_hash_cipher AS post_object_blur_hash_cipher,
- asset.width AS post_object_width,
- asset.height AS post_object_height,
- asset.media_type AS post_object_media_type
- FROM wall_messages m
- JOIN wall_posts p ON p.post_id = m.reply_post_id
- JOIN walls actor_wall ON actor_wall.wall_id = m.sender_wall_id AND actor_wall.owner_id = m.sender_id
- JOIN key_attributes actor_ka ON actor_ka.user_id = m.sender_id
- JOIN walls post_wall ON post_wall.wall_id = p.wall_id
- JOIN walls owner_wall ON owner_wall.wall_id = p.wall_id
- JOIN key_attributes owner_ka ON owner_ka.user_id = p.owner_id
- LEFT JOIN LATERAL (
- SELECT object_key, size, position, variant, blur_hash_cipher, width, height, media_type
- FROM wall_post_assets
- WHERE post_id = p.post_id
- ORDER BY position ASC, asset_id ASC
- LIMIT 1
- ) asset ON TRUE
- WHERE m.recipient_id = $1
- AND m.sender_id <> $1
- AND m.kind = 'post_reply'
- AND m.is_deleted = FALSE
- AND m.reply_post_id IS NOT NULL
- AND p.owner_id = $1
- AND p.is_deleted = FALSE
-`
-
-func (r *NotificationsRepository) List(ctx context.Context, userID int64, cursor string, limit int) ([]WallNotificationRecord, string, error) {
- limit = optionalInt(limit, 50)
- if limit > 100 {
- limit = 100
- }
- var cursorCreatedAt any
- var cursorID any
- if createdAt, id, ok := parseNotificationCursor(cursor); ok {
- cursorCreatedAt = createdAt
- cursorID = id
- }
- rows, err := r.DB.QueryContext(ctx, `
- WITH notifications AS (`+wallNotificationRows+`)
- SELECT n.*
- FROM notifications n
- WHERE ($2::bigint IS NULL OR (n.created_at, n.notification_id) < ($2::bigint, $3::text))
- ORDER BY n.created_at DESC, n.notification_id DESC
- LIMIT $4
- `, userID, cursorCreatedAt, cursorID, limit+1)
- if err != nil {
- return nil, "", stacktrace.Propagate(err, "")
- }
- defer rows.Close()
-
- out := make([]WallNotificationRecord, 0, limit+1)
- for rows.Next() {
- rec, err := scanNotificationRecord(rows)
- if err != nil {
- return nil, "", err
- }
- out = append(out, *rec)
- }
- if err := rows.Err(); err != nil {
- return nil, "", stacktrace.Propagate(err, "")
- }
- nextCursor := ""
- if len(out) > limit {
- nextCursor = formatNotificationCursor(out[limit-1])
- out = out[:limit]
- }
- return out, nextCursor, nil
-}
-
-func scanNotificationRecord(scanner interface{ Scan(dest ...any) error }) (*WallNotificationRecord, error) {
- var rec WallNotificationRecord
- dest := []any{&rec.ID, &rec.Type, &rec.CreatedAt}
- dest = append(dest, wallActorScanDest(&rec.Actor)...)
- dest = append(dest, &rec.PostID, &rec.PostWallID, &rec.PostWallSlug, &rec.PostOwnerID)
- dest = append(dest, wallActorScanDest(&rec.PostAuthor)...)
- dest = append(dest, &rec.PostObjectKey, &rec.PostObjectSize, &rec.PostObjectPosition, &rec.PostObjectVariant, &rec.PostObjectBlurHashCipher, &rec.PostObjectWidth, &rec.PostObjectHeight, &rec.PostObjectMediaType)
- if err := scanner.Scan(dest...); err != nil {
- return nil, stacktrace.Propagate(err, "")
- }
- return &rec, nil
-}
-
-func parseNotificationCursor(cursor string) (int64, string, bool) {
- createdAtText, id, ok := strings.Cut(strings.TrimSpace(cursor), ":")
- if !ok || strings.TrimSpace(id) == "" {
- return 0, "", false
- }
- createdAt, err := strconv.ParseInt(createdAtText, 10, 64)
- if err != nil || createdAt <= 0 {
- return 0, "", false
- }
- return createdAt, id, true
-}
-
-func formatNotificationCursor(notification WallNotificationRecord) string {
- return strconv.FormatInt(notification.CreatedAt, 10) + ":" + notification.ID
-}
diff --git a/web/packages/wasm/src/wall.rs b/web/packages/wasm/src/wall.rs
index 9905f6c62b..59177e9afa 100644
--- a/web/packages/wasm/src/wall.rs
+++ b/web/packages/wasm/src/wall.rs
@@ -6,7 +6,6 @@ use ente_wall::{
DecryptedPost, DecryptedWallProfile, MessageConversationActivity, MessageConversationPost,
MessageResponse, OpenAccountWallCtxInput, OpenWallLinkCtxInput, PostResponse, PrivateKeySource,
ProfileAvatarResponse, WallActorResponse, WallError as CoreWallError, WallLinkCtx,
- WallNotification, WallNotificationPost,
crypto::{decode_b64, encode_b64},
};
use serde::{Deserialize, Serialize};
@@ -172,35 +171,6 @@ struct PostPageJs {
next_cursor: String,
}
-#[derive(Serialize)]
-#[serde(rename_all = "camelCase")]
-struct NotificationPostJs {
- post_id: i64,
- wall_id: String,
- wall_slug: String,
- owner_user_id: i64,
- author: ActorJs,
- objects: Vec<ente_wall::PostObjectPayload>,
-}
-
-#[derive(Serialize)]
-#[serde(rename_all = "camelCase")]
-struct NotificationJs {
- id: String,
- #[serde(rename = "type")]
- notification_type: ente_wall::WallNotificationType,
- created_at: String,
- actor: ActorJs,
- post: Option<NotificationPostJs>,
-}
-
-#[derive(Serialize)]
-#[serde(rename_all = "camelCase")]
-struct NotificationPageJs {
- items: Vec<NotificationJs>,
- next_cursor: String,
-}
-
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct PostLikerJs {
@@ -449,39 +419,6 @@ async fn link_post_page_to_js(
})
}
-async fn notification_to_js(
- ctx: &AccountWallCtx,
- notification: WallNotification,
-) -> Result<NotificationJs, WasmWallError> {
- let post = match notification.post {
- Some(post) => Some(notification_post_to_js(ctx, post).await?),
- None => None,
- };
- let actor = account_actor_to_js(ctx, notification.actor).await?;
- Ok(NotificationJs {
- id: notification.id,
- notification_type: notification.notification_type,
- created_at: notification.created_at,
- actor,
- post,
- })
-}
-
-async fn notification_post_to_js(
- ctx: &AccountWallCtx,
- post: WallNotificationPost,
-) -> Result<NotificationPostJs, WasmWallError> {
- let author = account_actor_to_js(ctx, post.author).await?;
- Ok(NotificationPostJs {
- post_id: post.post_id,
- wall_id: post.wall_id,
- wall_slug: post.wall_slug,
- owner_user_id: post.owner_user_id,
- author,
- objects: post.objects,
- })
-}
-
async fn account_message_to_js(
ctx: &AccountWallCtx,
message: MessageResponse,
@@ -1045,24 +982,6 @@ impl WallAccountCtxHandle {
.await
.map_err(Into::into)
}
-
- /// List notifications.
- pub async fn list_notifications(
- &self,
- cursor: Option<String>,
- limit: Option<i32>,
- ) -> Result<JsValue, WasmWallError> {
- let page = self.inner.list_notifications(cursor, limit).await?;
- let mut items = Vec::with_capacity(page.items.len());
- for item in page.items {
- items.push(notification_to_js(&self.inner, item).await?);
- }
- swb::to_value(&NotificationPageJs {
- items,
- next_cursor: page.next_cursor,
- })
- .map_err(Into::into)
- }
}
/// Handle to a public wall link context.