the-algorithm/visibilitylib/src/main/scala/com/twitter/visibility/models/CommunityTweet.scala
twitter-team ef4c5eb65e Twitter Recommendation Algorithm
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
2023-03-31 17:36:31 -05:00

24 lines
675 B
Scala

package com.twitter.visibility.models
import com.twitter.tweetypie.thriftscala.Communities
import com.twitter.tweetypie.thriftscala.Tweet
object CommunityTweet {
def getCommunityId(communities: Communities): Option[CommunityId] =
communities.communityIds.headOption
def getCommunityId(tweet: Tweet): Option[CommunityId] =
tweet.communities.flatMap(getCommunityId)
def apply(tweet: Tweet): Option[CommunityTweet] =
getCommunityId(tweet).map { communityId =>
val authorId = tweet.coreData.get.userId
CommunityTweet(tweet, communityId, authorId)
}
}
case class CommunityTweet(
tweet: Tweet,
communityId: CommunityId,
authorId: Long)