Skip to content

Commit

Permalink
feat: add hidden protection to friend add route
Browse files Browse the repository at this point in the history
  • Loading branch information
raikasdev committed Mar 12, 2024
1 parent 54003c3 commit da61703
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions docs/APISPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,8 @@ curl --request POST 'https://api.testaustime.fi/friends/add' \
"project_name": "My Project",
"language": "javascript",
"editor_name": "vscode",
"hostname": "mylaptop"
"hostname": "mylaptop",
"hidden": false
}
}
}
Expand Down Expand Up @@ -1035,7 +1036,8 @@ curl --request GET ''https://api.testaustime.fi/friends/list' \
"project_name": "My Project",
"language": "javascript",
"editor_name": "vscode",
"hostname": "mylaptop"
"hostname": "mylaptop",
"hidden": true
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/api/friends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ pub async fn add_friend(
username: friend.username.clone(),
coding_time: db.get_coding_time_steps(friend.id).await,
status: heartbeats.get(&friend.id).map(|heartbeat| {
let (inner_heartbeat, start_time, duration) = heartbeat.to_owned();
let (mut inner_heartbeat, start_time, duration) = heartbeat.to_owned();
drop(heartbeat);
if inner_heartbeat.hidden == Some(true) {
inner_heartbeat.project_name = Some("".to_string());
}
CurrentActivity {
started: start_time,
duration: duration.num_seconds(),
Expand Down

0 comments on commit da61703

Please sign in to comment.