Skip to main content

Overview

The Posts_Model class represents a post in the Threadly application. It contains information about the post content, engagement metrics, and the user who created it.

Fields

CONTENT_TYPE
int
required
Content type indicator:
  • 0: Regular content post
  • 1: Suggested post
postId
int
required
Unique identifier for the post
userId
string
required
ID of the user who created the post
username
string
required
Username of the post creator
userDpUrl
string
required
URL to the user’s display picture/profile photo
postUrl
string
required
URL to the post media content
caption
string
required
Caption text for the post
createdAt
string
required
Timestamp when the post was created
likedBy
string
Username of a user who liked the post (used for displaying “Liked by…”)
likeCount
int
required
Total number of likes on the post
commentCount
int
required
Total number of comments on the post
shareCount
int
required
Total number of shares for the post
isliked
boolean
required
Whether the current user has liked this post
isVideo
boolean
required
Whether the post content is a video (true) or image (false)
isFollowed
boolean
required
Whether the current user follows the post creator

Methods

The model provides standard getter and setter methods for all fields:
  • getCONTENT_TYPE() / setCONTENT_TYPE(int)
  • getPostId() / setPostId(int)
  • getUserId() / setUserId(String)
  • getUsername() / setUsername(String)
  • getUserDpUrl() / setUserDpUrl(String)
  • getPostUrl() / setPostUrl(String)
  • getCaption() / setCaption(String)
  • getCreatedAt() / setCreatedAt(String)
  • getLikedBy() / setLikedBy(String)
  • getLikeCount() / setLikeCount(int)
  • getCommentCount() / setCommentCount(int)
  • getShareCount() / setShareCount(int)
  • getIsliked() / setIsliked(Boolean)
  • isVideo() / setVideo(boolean)
  • isFollowed() / setFollowed(boolean)

Example

{
  "CONTENT_TYPE": 0,
  "postId": 12345,
  "userId": "user_789",
  "username": "johndoe",
  "userDpUrl": "https://example.com/profiles/johndoe.jpg",
  "postUrl": "https://example.com/posts/12345.jpg",
  "caption": "Beautiful sunset at the beach!",
  "createdAt": "2024-03-15T18:30:00Z",
  "likedBy": "janedoe",
  "likeCount": 142,
  "commentCount": 23,
  "shareCount": 8,
  "isliked": true,
  "isVideo": false,
  "isFollowed": true
}

Usage Notes

  • The CONTENT_TYPE field distinguishes between regular content (0) and suggested/recommended posts (1)
  • The isliked field is derived from an integer value during construction (>0 = true)
  • Both image and video posts use the same model, differentiated by the isVideo flag
  • Engagement metrics (likeCount, commentCount, shareCount) are updated as users interact with the post

Build docs developers (and LLMs) love