Skip to content

Commit

Permalink
chore: remove user-presence
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Oct 17, 2024
1 parent 0ef9611 commit 60be979
Show file tree
Hide file tree
Showing 129 changed files with 87 additions and 2,669 deletions.
10 changes: 0 additions & 10 deletions fern/definition/identity/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ types:
avatar_url:
type: string
docs: The URL of this identity's avatar image.
presence: optional<Presence>
is_registered:
type: boolean
docs: Whether or not this identity is registered with a linked account.
Expand All @@ -97,7 +96,6 @@ types:
avatar_url:
type: string
docs: The URL of this identity's avatar image.
presence: optional<Presence>
is_registered:
type: boolean
docs: Whether or not this identity is registered with a linked account.
Expand All @@ -120,7 +118,6 @@ types:
avatar_url:
docs: The URL of this identity's avatar image.
type: string
presence: optional<Presence>
is_registered:
docs: Whether or not this identity is registered with a linked account.
type: boolean
Expand Down Expand Up @@ -166,13 +163,6 @@ types:
type: optional<string>
docs: A link to the Rivet settings page.

Presence:
docs: Information about the identity's current status, party, and active game.
properties:
update_ts: commons.Timestamp
status: Status
game_activity: optional<GameActivity>

Status:
docs: The current status of an identity. This helps players understand if
another player is currently playing or has their game in the background.
Expand Down
4 changes: 0 additions & 4 deletions lib/chirp-workflow/core/src/ctx/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ impl ActivityCtx {
self.conn.redis_mm().await
}

pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
self.conn.redis_user_presence().await
}

pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
self.conn.clickhouse().await
}
Expand Down
4 changes: 0 additions & 4 deletions lib/chirp-workflow/core/src/ctx/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,6 @@ impl ApiCtx {
self.conn.redis_mm().await
}

pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
self.conn.redis_user_presence().await
}

pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
self.conn.clickhouse().await
}
Expand Down
4 changes: 0 additions & 4 deletions lib/chirp-workflow/core/src/ctx/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ impl OperationCtx {
self.conn.redis_mm().await
}

pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
self.conn.redis_user_presence().await
}

pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
self.conn.clickhouse().await
}
Expand Down
4 changes: 0 additions & 4 deletions lib/chirp-workflow/core/src/ctx/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ impl StandaloneCtx {
self.conn.redis_mm().await
}

pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
self.conn.redis_user_presence().await
}

pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
self.conn.clickhouse().await
}
Expand Down
4 changes: 0 additions & 4 deletions lib/chirp-workflow/core/src/ctx/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,6 @@ impl TestCtx {
self.conn.redis_mm().await
}

pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
self.conn.redis_user_presence().await
}

pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
self.conn.clickhouse().await
}
Expand Down
4 changes: 0 additions & 4 deletions lib/chirp/worker/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ impl TestCtx {
self.op_ctx.redis_mm().await
}

pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
self.op_ctx.redis_user_presence().await
}

pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
self.op_ctx.clickhouse().await
}
Expand Down
4 changes: 0 additions & 4 deletions lib/connection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ impl Connection {
self.pools.redis("persistent")
}

pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
self.pools.redis("ephemeral")
}

pub async fn redis_chirp_ephemeral(&self) -> Result<RedisPool, rivet_pools::Error> {
self.pools.redis("ephemeral")
}
Expand Down
1 change: 0 additions & 1 deletion lib/convert/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ user-follow-count = { path = "../../svc/pkg/user-follow/ops/count" }
user-follow-get = { path = "../../svc/pkg/user-follow/ops/get" }
user-get = { path = "../../svc/pkg/user/ops/get" }
user-identity-get = { path = "../../svc/pkg/user-identity/ops/get" }
user-presence-get = { path = "../../svc/pkg/user-presence/ops/get" }
user-team-list = { path = "../../svc/pkg/user/ops/team-list" }

rivet-api = { path = "../../sdks/full/rust" }
Expand Down
111 changes: 0 additions & 111 deletions lib/convert/src/convert/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,16 @@ use crate::{convert, fetch, ApiTryInto};
pub fn handle(
current_user_id: Uuid,
user: &backend::user::User,
presences_ctx: &fetch::identity::PresencesCtx,
is_mutual_following: bool,
) -> GlobalResult<models::IdentityHandle> {
let user_id = unwrap_ref!(user.user_id).as_uuid();
let is_self = user_id == current_user_id;

let user_presence = unwrap!(presences_ctx
.res
.users
.iter()
.find(|presence| presence.user_id == user.user_id));
let user_presence = unwrap_ref!(user_presence.presence);
let _status = unwrap!(backend::user::Status::from_i32(user_presence.status));

Ok(models::IdentityHandle {
identity_id: user_id,
display_name: user.display_name.clone(),
account_number: user.account_number as i32,
avatar_url: util::route::user_avatar(&user),
presence: Some(Box::new(presence(
user_presence,
&presences_ctx.games,
is_self || is_mutual_following,
)?)),
is_registered: true, // TODO:
external: Box::new(models::IdentityExternalLinks {
profile: util::route::user_profile(user_id),
settings: None,
}),
})
}

pub fn handle_without_presence(
current_user_id: Uuid,
user: &backend::user::User,
) -> GlobalResult<models::IdentityHandle> {
let user_id = unwrap_ref!(user.user_id).as_uuid();
let _is_self = user_id == current_user_id;

Ok(models::IdentityHandle {
identity_id: user_id,
display_name: user.display_name.to_owned(),
account_number: user.account_number as i32,
avatar_url: util::route::user_avatar(&user),
presence: None,
is_registered: true, // TODO:
external: Box::new(models::IdentityExternalLinks {
profile: util::route::user_profile(user_id),
Expand All @@ -66,20 +31,12 @@ pub fn handle_without_presence(
pub fn summary(
current_user_id: Uuid,
user: &backend::user::User,
presences_ctx: &fetch::identity::PresencesCtx,
mutual_follows: &[user_follow::get::response::Follow],
) -> GlobalResult<models::IdentitySummary> {
let user_id_proto = unwrap!(user.user_id);
let user_id = user_id_proto.as_uuid();
let is_self = user_id == current_user_id;

let user_presence = unwrap!(presences_ctx
.res
.users
.iter()
.find(|presence| presence.user_id == user.user_id));
let user_presence = unwrap_ref!(user_presence.presence);

let current_user_id = Into::<common::Uuid>::into(current_user_id);
let following = mutual_follows.iter().any(|follow| {
follow.follower_user_id.as_ref() == Some(&current_user_id)
Expand All @@ -96,11 +53,6 @@ pub fn summary(
display_name: user.display_name.clone(),
account_number: user.account_number as i32,
avatar_url: util::route::user_avatar(&user),
presence: Some(Box::new(presence(
user_presence,
&presences_ctx.games,
is_self || is_mutual_following,
)?)),
is_registered: true, // TODO:
external: Box::new(models::IdentityExternalLinks {
profile: util::route::user_profile(user_id),
Expand All @@ -114,7 +66,6 @@ pub fn summary(

#[derive(Debug)]
pub struct ProfileCtx<'a> {
pub presences_ctx: &'a fetch::identity::PresencesCtx,
pub teams_ctx: &'a fetch::identity::TeamsCtx,
pub mutual_follows: &'a [user_follow::get::response::Follow],
pub follower_counts: &'a [user_follow::count::response::Follows],
Expand Down Expand Up @@ -172,15 +123,6 @@ pub fn profile(
.collect::<GlobalResult<Vec<_>>>()?
};

let user_presence = unwrap!(pctx
.presences_ctx
.res
.users
.iter()
.find(|presence| presence.user_id == user.user_id));
let user_presence = unwrap_ref!(user_presence.presence);
let _status = unwrap!(backend::user::Status::from_i32(user_presence.status));

let current_user_id = Into::<common::Uuid>::into(current_user_id);
let following = pctx.mutual_follows.iter().any(|follow| {
follow.follower_user_id.as_ref() == Some(&current_user_id)
Expand Down Expand Up @@ -210,11 +152,6 @@ pub fn profile(
display_name: user.display_name.to_owned(),
account_number: user.account_number as i32,
avatar_url: util::route::user_avatar(&user),
presence: Some(Box::new(presence(
user_presence,
&pctx.presences_ctx.games,
is_self || is_mutual_following,
)?)),
is_registered,
external: Box::new(models::IdentityExternalLinks {
profile: util::route::user_profile(user_id),
Expand Down Expand Up @@ -247,51 +184,3 @@ pub fn profile(
games: Vec::new(), // TODO:
})
}

pub fn presence(
presence: &backend::user::Presence,
games: &[backend::game::Game],
is_mutual_following: bool,
) -> GlobalResult<models::IdentityPresence> {
let status = unwrap!(backend::user::Status::from_i32(presence.status));

let game_activity = if let Some(game_activity) = &presence.game_activity {
let game_id = unwrap_ref!(game_activity.game_id);

let game = unwrap!(games
.iter()
.find(|game| game.game_id.as_ref() == Some(game_id)));

Some(Box::new(models::IdentityGameActivity {
game: Box::new(convert::game::handle(game)?),
message: game_activity.message.to_owned(),
public_metadata: game_activity
.public_metadata
.as_ref()
.and_then(|s| serde_json::from_str(s).ok()),
mutual_metadata: if is_mutual_following {
game_activity
.friend_metadata
.as_ref()
.and_then(|s| serde_json::from_str(s).ok())
} else {
None
},
}))
} else {
None
};

Ok(models::IdentityPresence {
update_ts: util::timestamp::to_string(presence.update_ts)?,
status: match status {
backend::user::Status::Offline => models::IdentityStatus::Offline,
backend::user::Status::Away => models::IdentityStatus::Away,
backend::user::Status::Online => models::IdentityStatus::Online,
},
game_activity: match status {
backend::user::Status::Offline => None,
_ => game_activity,
},
})
}
Loading

0 comments on commit 60be979

Please sign in to comment.