Skip to content

Commit 450f1ab

Browse files
committed
chore: remove user-presence (#1207)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
1 parent 0ef9611 commit 450f1ab

File tree

129 files changed

+87
-2669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+87
-2669
lines changed

fern/definition/identity/common.yml

-10
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ types:
8282
avatar_url:
8383
type: string
8484
docs: The URL of this identity's avatar image.
85-
presence: optional<Presence>
8685
is_registered:
8786
type: boolean
8887
docs: Whether or not this identity is registered with a linked account.
@@ -97,7 +96,6 @@ types:
9796
avatar_url:
9897
type: string
9998
docs: The URL of this identity's avatar image.
100-
presence: optional<Presence>
10199
is_registered:
102100
type: boolean
103101
docs: Whether or not this identity is registered with a linked account.
@@ -120,7 +118,6 @@ types:
120118
avatar_url:
121119
docs: The URL of this identity's avatar image.
122120
type: string
123-
presence: optional<Presence>
124121
is_registered:
125122
docs: Whether or not this identity is registered with a linked account.
126123
type: boolean
@@ -166,13 +163,6 @@ types:
166163
type: optional<string>
167164
docs: A link to the Rivet settings page.
168165

169-
Presence:
170-
docs: Information about the identity's current status, party, and active game.
171-
properties:
172-
update_ts: commons.Timestamp
173-
status: Status
174-
game_activity: optional<GameActivity>
175-
176166
Status:
177167
docs: The current status of an identity. This helps players understand if
178168
another player is currently playing or has their game in the background.

lib/chirp-workflow/core/src/ctx/activity.rs

-4
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@ impl ActivityCtx {
162162
self.conn.redis_mm().await
163163
}
164164

165-
pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
166-
self.conn.redis_user_presence().await
167-
}
168-
169165
pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
170166
self.conn.clickhouse().await
171167
}

lib/chirp-workflow/core/src/ctx/api.rs

-4
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,6 @@ impl ApiCtx {
232232
self.conn.redis_mm().await
233233
}
234234

235-
pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
236-
self.conn.redis_user_presence().await
237-
}
238-
239235
pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
240236
self.conn.clickhouse().await
241237
}

lib/chirp-workflow/core/src/ctx/operation.rs

-4
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ impl OperationCtx {
157157
self.conn.redis_mm().await
158158
}
159159

160-
pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
161-
self.conn.redis_user_presence().await
162-
}
163-
164160
pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
165161
self.conn.clickhouse().await
166162
}

lib/chirp-workflow/core/src/ctx/standalone.rs

-4
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,6 @@ impl StandaloneCtx {
235235
self.conn.redis_mm().await
236236
}
237237

238-
pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
239-
self.conn.redis_user_presence().await
240-
}
241-
242238
pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
243239
self.conn.clickhouse().await
244240
}

lib/chirp-workflow/core/src/ctx/test.rs

-4
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,6 @@ impl TestCtx {
254254
self.conn.redis_mm().await
255255
}
256256

257-
pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
258-
self.conn.redis_user_presence().await
259-
}
260-
261257
pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
262258
self.conn.clickhouse().await
263259
}

lib/chirp/worker/src/test.rs

-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ impl TestCtx {
7979
self.op_ctx.redis_mm().await
8080
}
8181

82-
pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
83-
self.op_ctx.redis_user_presence().await
84-
}
85-
8682
pub async fn clickhouse(&self) -> GlobalResult<ClickHousePool> {
8783
self.op_ctx.clickhouse().await
8884
}

lib/connection/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ impl Connection {
9595
self.pools.redis("persistent")
9696
}
9797

98-
pub async fn redis_user_presence(&self) -> Result<RedisPool, rivet_pools::Error> {
99-
self.pools.redis("ephemeral")
100-
}
101-
10298
pub async fn redis_chirp_ephemeral(&self) -> Result<RedisPool, rivet_pools::Error> {
10399
self.pools.redis("ephemeral")
104100
}

lib/convert/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ user-follow-count = { path = "../../svc/pkg/user-follow/ops/count" }
4242
user-follow-get = { path = "../../svc/pkg/user-follow/ops/get" }
4343
user-get = { path = "../../svc/pkg/user/ops/get" }
4444
user-identity-get = { path = "../../svc/pkg/user-identity/ops/get" }
45-
user-presence-get = { path = "../../svc/pkg/user-presence/ops/get" }
4645
user-team-list = { path = "../../svc/pkg/user/ops/team-list" }
4746

4847
rivet-api = { path = "../../sdks/full/rust" }

lib/convert/src/convert/identity.rs

-111
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,16 @@ use crate::{convert, fetch, ApiTryInto};
1010
pub fn handle(
1111
current_user_id: Uuid,
1212
user: &backend::user::User,
13-
presences_ctx: &fetch::identity::PresencesCtx,
1413
is_mutual_following: bool,
1514
) -> GlobalResult<models::IdentityHandle> {
1615
let user_id = unwrap_ref!(user.user_id).as_uuid();
1716
let is_self = user_id == current_user_id;
1817

19-
let user_presence = unwrap!(presences_ctx
20-
.res
21-
.users
22-
.iter()
23-
.find(|presence| presence.user_id == user.user_id));
24-
let user_presence = unwrap_ref!(user_presence.presence);
25-
let _status = unwrap!(backend::user::Status::from_i32(user_presence.status));
26-
2718
Ok(models::IdentityHandle {
2819
identity_id: user_id,
2920
display_name: user.display_name.clone(),
3021
account_number: user.account_number as i32,
3122
avatar_url: util::route::user_avatar(&user),
32-
presence: Some(Box::new(presence(
33-
user_presence,
34-
&presences_ctx.games,
35-
is_self || is_mutual_following,
36-
)?)),
37-
is_registered: true, // TODO:
38-
external: Box::new(models::IdentityExternalLinks {
39-
profile: util::route::user_profile(user_id),
40-
settings: None,
41-
}),
42-
})
43-
}
44-
45-
pub fn handle_without_presence(
46-
current_user_id: Uuid,
47-
user: &backend::user::User,
48-
) -> GlobalResult<models::IdentityHandle> {
49-
let user_id = unwrap_ref!(user.user_id).as_uuid();
50-
let _is_self = user_id == current_user_id;
51-
52-
Ok(models::IdentityHandle {
53-
identity_id: user_id,
54-
display_name: user.display_name.to_owned(),
55-
account_number: user.account_number as i32,
56-
avatar_url: util::route::user_avatar(&user),
57-
presence: None,
5823
is_registered: true, // TODO:
5924
external: Box::new(models::IdentityExternalLinks {
6025
profile: util::route::user_profile(user_id),
@@ -66,20 +31,12 @@ pub fn handle_without_presence(
6631
pub fn summary(
6732
current_user_id: Uuid,
6833
user: &backend::user::User,
69-
presences_ctx: &fetch::identity::PresencesCtx,
7034
mutual_follows: &[user_follow::get::response::Follow],
7135
) -> GlobalResult<models::IdentitySummary> {
7236
let user_id_proto = unwrap!(user.user_id);
7337
let user_id = user_id_proto.as_uuid();
7438
let is_self = user_id == current_user_id;
7539

76-
let user_presence = unwrap!(presences_ctx
77-
.res
78-
.users
79-
.iter()
80-
.find(|presence| presence.user_id == user.user_id));
81-
let user_presence = unwrap_ref!(user_presence.presence);
82-
8340
let current_user_id = Into::<common::Uuid>::into(current_user_id);
8441
let following = mutual_follows.iter().any(|follow| {
8542
follow.follower_user_id.as_ref() == Some(&current_user_id)
@@ -96,11 +53,6 @@ pub fn summary(
9653
display_name: user.display_name.clone(),
9754
account_number: user.account_number as i32,
9855
avatar_url: util::route::user_avatar(&user),
99-
presence: Some(Box::new(presence(
100-
user_presence,
101-
&presences_ctx.games,
102-
is_self || is_mutual_following,
103-
)?)),
10456
is_registered: true, // TODO:
10557
external: Box::new(models::IdentityExternalLinks {
10658
profile: util::route::user_profile(user_id),
@@ -114,7 +66,6 @@ pub fn summary(
11466

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

175-
let user_presence = unwrap!(pctx
176-
.presences_ctx
177-
.res
178-
.users
179-
.iter()
180-
.find(|presence| presence.user_id == user.user_id));
181-
let user_presence = unwrap_ref!(user_presence.presence);
182-
let _status = unwrap!(backend::user::Status::from_i32(user_presence.status));
183-
184126
let current_user_id = Into::<common::Uuid>::into(current_user_id);
185127
let following = pctx.mutual_follows.iter().any(|follow| {
186128
follow.follower_user_id.as_ref() == Some(&current_user_id)
@@ -210,11 +152,6 @@ pub fn profile(
210152
display_name: user.display_name.to_owned(),
211153
account_number: user.account_number as i32,
212154
avatar_url: util::route::user_avatar(&user),
213-
presence: Some(Box::new(presence(
214-
user_presence,
215-
&pctx.presences_ctx.games,
216-
is_self || is_mutual_following,
217-
)?)),
218155
is_registered,
219156
external: Box::new(models::IdentityExternalLinks {
220157
profile: util::route::user_profile(user_id),
@@ -247,51 +184,3 @@ pub fn profile(
247184
games: Vec::new(), // TODO:
248185
})
249186
}
250-
251-
pub fn presence(
252-
presence: &backend::user::Presence,
253-
games: &[backend::game::Game],
254-
is_mutual_following: bool,
255-
) -> GlobalResult<models::IdentityPresence> {
256-
let status = unwrap!(backend::user::Status::from_i32(presence.status));
257-
258-
let game_activity = if let Some(game_activity) = &presence.game_activity {
259-
let game_id = unwrap_ref!(game_activity.game_id);
260-
261-
let game = unwrap!(games
262-
.iter()
263-
.find(|game| game.game_id.as_ref() == Some(game_id)));
264-
265-
Some(Box::new(models::IdentityGameActivity {
266-
game: Box::new(convert::game::handle(game)?),
267-
message: game_activity.message.to_owned(),
268-
public_metadata: game_activity
269-
.public_metadata
270-
.as_ref()
271-
.and_then(|s| serde_json::from_str(s).ok()),
272-
mutual_metadata: if is_mutual_following {
273-
game_activity
274-
.friend_metadata
275-
.as_ref()
276-
.and_then(|s| serde_json::from_str(s).ok())
277-
} else {
278-
None
279-
},
280-
}))
281-
} else {
282-
None
283-
};
284-
285-
Ok(models::IdentityPresence {
286-
update_ts: util::timestamp::to_string(presence.update_ts)?,
287-
status: match status {
288-
backend::user::Status::Offline => models::IdentityStatus::Offline,
289-
backend::user::Status::Away => models::IdentityStatus::Away,
290-
backend::user::Status::Online => models::IdentityStatus::Online,
291-
},
292-
game_activity: match status {
293-
backend::user::Status::Offline => None,
294-
_ => game_activity,
295-
},
296-
})
297-
}

0 commit comments

Comments
 (0)