@@ -10,51 +10,16 @@ use crate::{convert, fetch, ApiTryInto};
10
10
pub fn handle (
11
11
current_user_id : Uuid ,
12
12
user : & backend:: user:: User ,
13
- presences_ctx : & fetch:: identity:: PresencesCtx ,
14
13
is_mutual_following : bool ,
15
14
) -> GlobalResult < models:: IdentityHandle > {
16
15
let user_id = unwrap_ref ! ( user. user_id) . as_uuid ( ) ;
17
16
let is_self = user_id == current_user_id;
18
17
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
-
27
18
Ok ( models:: IdentityHandle {
28
19
identity_id : user_id,
29
20
display_name : user. display_name . clone ( ) ,
30
21
account_number : user. account_number as i32 ,
31
22
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 ,
58
23
is_registered : true , // TODO:
59
24
external : Box :: new ( models:: IdentityExternalLinks {
60
25
profile : util:: route:: user_profile ( user_id) ,
@@ -66,20 +31,12 @@ pub fn handle_without_presence(
66
31
pub fn summary (
67
32
current_user_id : Uuid ,
68
33
user : & backend:: user:: User ,
69
- presences_ctx : & fetch:: identity:: PresencesCtx ,
70
34
mutual_follows : & [ user_follow:: get:: response:: Follow ] ,
71
35
) -> GlobalResult < models:: IdentitySummary > {
72
36
let user_id_proto = unwrap ! ( user. user_id) ;
73
37
let user_id = user_id_proto. as_uuid ( ) ;
74
38
let is_self = user_id == current_user_id;
75
39
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
-
83
40
let current_user_id = Into :: < common:: Uuid > :: into ( current_user_id) ;
84
41
let following = mutual_follows. iter ( ) . any ( |follow| {
85
42
follow. follower_user_id . as_ref ( ) == Some ( & current_user_id)
@@ -96,11 +53,6 @@ pub fn summary(
96
53
display_name : user. display_name . clone ( ) ,
97
54
account_number : user. account_number as i32 ,
98
55
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
- ) ?) ) ,
104
56
is_registered : true , // TODO:
105
57
external : Box :: new ( models:: IdentityExternalLinks {
106
58
profile : util:: route:: user_profile ( user_id) ,
@@ -114,7 +66,6 @@ pub fn summary(
114
66
115
67
#[ derive( Debug ) ]
116
68
pub struct ProfileCtx < ' a > {
117
- pub presences_ctx : & ' a fetch:: identity:: PresencesCtx ,
118
69
pub teams_ctx : & ' a fetch:: identity:: TeamsCtx ,
119
70
pub mutual_follows : & ' a [ user_follow:: get:: response:: Follow ] ,
120
71
pub follower_counts : & ' a [ user_follow:: count:: response:: Follows ] ,
@@ -172,15 +123,6 @@ pub fn profile(
172
123
. collect :: < GlobalResult < Vec < _ > > > ( ) ?
173
124
} ;
174
125
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
-
184
126
let current_user_id = Into :: < common:: Uuid > :: into ( current_user_id) ;
185
127
let following = pctx. mutual_follows . iter ( ) . any ( |follow| {
186
128
follow. follower_user_id . as_ref ( ) == Some ( & current_user_id)
@@ -210,11 +152,6 @@ pub fn profile(
210
152
display_name : user. display_name . to_owned ( ) ,
211
153
account_number : user. account_number as i32 ,
212
154
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
- ) ?) ) ,
218
155
is_registered,
219
156
external : Box :: new ( models:: IdentityExternalLinks {
220
157
profile : util:: route:: user_profile ( user_id) ,
@@ -247,51 +184,3 @@ pub fn profile(
247
184
games : Vec :: new ( ) , // TODO:
248
185
} )
249
186
}
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