mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-01 08:48:46 +02:00
ef4c5eb65e
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.
24 lines
675 B
Scala
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)
|