π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Include parentCommentUserID in comment API responses
ashilkn4107eac42021
diff --git a/server/ente/social/comment.go b/server/ente/social/comment.goindex 8f08fabab9..d2b801bbe3 100644--- a/server/ente/social/comment.go+++ b/server/ente/social/comment.go@@ -5,7 +5,8 @@ type Comment struct {ID string `json:"id"`CollectionID int64 `json:"collectionID"`FileID *int64 `json:"fileID,omitempty"`- ParentCommentID *string `json:"parentCommentID,omitempty"`+ ParentCommentID *string `json:"parentCommentID,omitempty"`+ ParentCommentUserID *int64 `json:"parentCommentUserID,omitempty"`UserID int64 `json:"userID"`AnonUserID *string `json:"anonUserID,omitempty"`Cipher string `json:"cipher,omitempty"`diff --git a/server/pkg/repo/social/comments.go b/server/pkg/repo/social/comments.goindex 8794d9de9d..b2537748f8 100644--- a/server/pkg/repo/social/comments.go+++ b/server/pkg/repo/social/comments.go@@ -95,22 +95,26 @@ func (repo *CommentsRepository) SoftDeleteByCollectionAndUser(ctx context.Contexfunc (repo *CommentsRepository) GetByID(ctx context.Context, id string) (*socialentity.Comment, error) {var (- fileID sql.NullInt64- parent sql.NullString- anon sql.NullString- cipher sql.NullString- nonce sql.NullString+ fileID sql.NullInt64+ parent sql.NullString+ parentUserID sql.NullInt64+ anon sql.NullString+ cipher sql.NullString+ nonce sql.NullString)comment := &socialentity.Comment{}err := repo.DB.QueryRowContext(ctx, `- SELECT id, collection_id, file_id, parent_comment_id, user_id, anon_user_id, cipher, nonce, is_deleted, created_at, updated_at- FROM comments- WHERE id = $1+ SELECT c.id, c.collection_id, c.file_id, c.parent_comment_id, p.user_id,+ c.user_id, c.anon_user_id, c.cipher, c.nonce, c.is_deleted, c.created_at, c.updated_at+ FROM comments c+ LEFT JOIN comments p ON c.parent_comment_id = p.id+ WHERE c.id = $1`, id).Scan(&comment.ID,&comment.CollectionID,&fileID,&parent,+ &parentUserID,&comment.UserID,&anon,&cipher,@@ -128,6 +132,9 @@ func (repo *CommentsRepository) GetByID(ctx context.Context, id string) (*socialif parent.Valid {comment.ParentCommentID = &parent.String}+ if parentUserID.Valid {+ comment.ParentCommentUserID = &parentUserID.Int64+ }if anon.Valid {comment.AnonUserID = &anon.String}@@ -142,12 +149,14 @@ func (repo *CommentsRepository) GetByID(ctx context.Context, id string) (*socialfunc (repo *CommentsRepository) GetDiff(ctx context.Context, collectionID int64, since int64, limit int, fileID *int64) ([]socialentity.Comment, bool, error) {query := `- SELECT id, collection_id, file_id, parent_comment_id, user_id, anon_user_id, cipher, nonce, is_deleted, created_at, updated_at- FROM comments- WHERE collection_id = $1- AND updated_at > $2- AND ($3::BIGINT IS NULL OR file_id IS NOT DISTINCT FROM $3::BIGINT)- ORDER BY updated_at ASC+ SELECT c.id, c.collection_id, c.file_id, c.parent_comment_id, p.user_id,+ c.user_id, c.anon_user_id, c.cipher, c.nonce, c.is_deleted, c.created_at, c.updated_at+ FROM comments c+ LEFT JOIN comments p ON c.parent_comment_id = p.id+ WHERE c.collection_id = $1+ AND c.updated_at > $2+ AND ($3::BIGINT IS NULL OR c.file_id IS NOT DISTINCT FROM $3::BIGINT)+ ORDER BY c.updated_at ASCLIMIT $4`rows, err := repo.DB.QueryContext(ctx, query, collectionID, since, fileID, limit+1)@@ -159,18 +168,20 @@ func (repo *CommentsRepository) GetDiff(ctx context.Context, collectionID int64,comments := make([]socialentity.Comment, 0, limit+1)for rows.Next() {var (- file sql.NullInt64- parent sql.NullString- anon sql.NullString- cipher sql.NullString- nonce sql.NullString- comment socialentity.Comment+ file sql.NullInt64+ parent sql.NullString+ parentUserID sql.NullInt64+ anon sql.NullString+ cipher sql.NullString+ nonce sql.NullString+ comment socialentity.Comment)if err := rows.Scan(&comment.ID,&comment.CollectionID,&file,&parent,+ &parentUserID,&comment.UserID,&anon,&cipher,@@ -187,6 +198,9 @@ func (repo *CommentsRepository) GetDiff(ctx context.Context, collectionID int64,if parent.Valid {comment.ParentCommentID = &parent.String}+ if parentUserID.Valid {+ comment.ParentCommentUserID = &parentUserID.Int64+ }if anon.Valid {comment.AnonUserID = &anon.String}@@ -304,7 +318,7 @@ func (repo *CommentsRepository) GetActiveUserIDs(ctx context.Context, collection// 2. Replies to user's commentsfunc (repo *CommentsRepository) GetAlbumFeedComments(ctx context.Context, collectionID int64, userID int64, since int64, limit int) ([]socialentity.Comment, bool, error) {query := `- SELECT c.id, c.collection_id, c.file_id, c.parent_comment_id,+ SELECT c.id, c.collection_id, c.file_id, c.parent_comment_id, p.user_id,c.user_id, c.anon_user_id, c.cipher, c.nonce, c.is_deleted, c.created_at, c.updated_atFROM comments cLEFT JOIN comments p ON c.parent_comment_id = p.id@@ -336,18 +350,20 @@ func (repo *CommentsRepository) GetAlbumFeedComments(ctx context.Context, colleccomments := make([]socialentity.Comment, 0, limit+1)for rows.Next() {var (- file sql.NullInt64- parent sql.NullString- anon sql.NullString- cipher sql.NullString- nonce sql.NullString- comment socialentity.Comment+ file sql.NullInt64+ parent sql.NullString+ parentUserID sql.NullInt64+ anon sql.NullString+ cipher sql.NullString+ nonce sql.NullString+ comment socialentity.Comment)if err := rows.Scan(&comment.ID,&comment.CollectionID,&file,&parent,+ &parentUserID,&comment.UserID,&anon,&cipher,@@ -364,6 +380,9 @@ func (repo *CommentsRepository) GetAlbumFeedComments(ctx context.Context, collecif parent.Valid {comment.ParentCommentID = &parent.String}+ if parentUserID.Valid {+ comment.ParentCommentUserID = &parentUserID.Int64+ }if anon.Valid {comment.AnonUserID = &anon.String}