Friendships, likes, shares, and social discovery behavior.
The social feature connects readers through friend search, friend requests, accepted friendships, article shares, activity inbox rows, and liked article archives.
Primary social tables:
friendshipssharescontent_likesSupporting tables:
users for profiles and search results.content for article previews and like counts.threads and thread_messages when shares become chat messages.FriendsService.searchUsers queries users with a minimum two-character query and excludes the current user.
sendFriendRequest:
pending or accepted rows.friendships row with status: pending and createdAt.acceptFriendRequest updates status to accepted.
declineFriendRequest deletes the friendship row.
getFriends reads accepted rows in both directions, resolves the other user ID, hydrates users rows, and returns UserModel instances.
FriendsService.shareArticle requires that the sender matches the current signed-in user. When functions are configured, it executes chat_write with action shareArticle.
The function:
shares row with senderId, recipientId, contentId, optional encrypted message, sentAt, and isRead: false.thread_messages.threads.lastMessageAt.receivedSharesProvider reads shares where recipientId is the current user. sharePreviewProvider hydrates sender username and article title.
content_likes stores one row per user/content pair through the user_content_unique index.
LikeService:
userId, contentId, and likedAt.like_sync to update content.likeCount.ArchiveScreen shows a Liked tab. It pages through content_likes ordered by likedAt, hydrates each content row, and shows article tiles.
FriendsScreen has three tabs:
Find: debounced username/profile search and Add button.Friends: accepted friends and chat entry points.Activity: pending friend requests plus received article shares.Article sharing starts from ArticleDetailScreen through ShareArticleSheet, which lists accepted friends, supports selecting multiple recipients, accepts an optional message, and submits one share per selected friend through FriendsService.