+impl CommunityFollower {
+ pub fn to_subscribed_type(follower: &Option<Self>) -> SubscribedType {
+ match follower {
+ Some(f) => {
+ if f.pending {
+ SubscribedType::Pending
+ } else {
+ SubscribedType::Subscribed
+ }
+ }
+ // If the row doesn't exist, the person isn't a follower.
+ None => SubscribedType::NotSubscribed,
+ }
+ }
+
+ pub fn select_subscribed_type() -> dsl::Nullable<community_follower::pending> {
+ community_follower::pending.nullable()
+ }
+}
+
+impl Queryable<sql_types::Nullable<sql_types::Bool>, Pg> for SubscribedType {
+ type Row = Option<bool>;
+ fn build(row: Self::Row) -> deserialize::Result<Self> {
+ Ok(match row {
+ Some(true) => SubscribedType::Pending,
+ Some(false) => SubscribedType::Subscribed,
+ None => SubscribedType::NotSubscribed,
+ })
+ }
+}
+
+#[async_trait]