Ponder

Social Feature

Friendships, likes, shares, and social discovery behavior.

Purpose

The social feature connects readers through friend search, friend requests, accepted friendships, article shares, activity inbox rows, and liked article archives.

Tables

Primary social tables:

Supporting tables:

Friendships

FriendsService.searchUsers queries users with a minimum two-character query and excludes the current user.

sendFriendRequest:

  1. Requires a signed-in current user.
  2. Rejects empty or self requests.
  3. Checks both requester/addressee directions for existing pending or accepted rows.
  4. Creates a 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.

Shares

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:

  1. Reads the current user from Appwrite execution headers.
  2. Requires accepted friendship between sender and recipient.
  3. Gets or creates a 1:1 thread.
  4. Creates a shares row with senderId, recipientId, contentId, optional encrypted message, sentAt, and isRead: false.
  5. Creates a typed article message in thread_messages.
  6. Updates threads.lastMessageAt.

receivedSharesProvider reads shares where recipientId is the current user. sharePreviewProvider hydrates sender username and article title.

Likes

content_likes stores one row per user/content pair through the user_content_unique index.

LikeService:

ArchiveScreen shows a Liked tab. It pages through content_likes ordered by likedAt, hydrates each content row, and shows article tiles.

UI

FriendsScreen has three tabs:

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.