Skip to content

Commit

Permalink
feat: nsfw flag in posts (#208)
Browse files Browse the repository at this point in the history
* add flag for nsfw content in post struct

* fix tests; update candid files
  • Loading branch information
ravi-sawlani-yral authored Jan 2, 2024
1 parent f5488d8 commit d9e9ed4
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/canister/data_backup/can.did
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type MintEvent = variant {
};
type Post = record {
id : nat64;
is_nsfw : bool;
status : PostStatus;
share_count : nat64;
hashtags : vec text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ mod test {
let all_user_posts_from_individual_user_canister = vec![
Post {
id: 0,
is_nsfw: false,
description: "alice post 0 - description".to_string(),
hashtags: ["alice-tag-0".to_string(), "alice-tag-1".to_string()].to_vec(),
video_uid: "alice-video-0".to_string(),
Expand All @@ -107,6 +108,7 @@ mod test {
},
Post {
id: 1,
is_nsfw: false,
description: "alice post 1 - description".to_string(),
hashtags: ["alice-tag-2".to_string(), "alice-tag-3".to_string()].to_vec(),
video_uid: "alice-video-1".to_string(),
Expand Down
3 changes: 3 additions & 0 deletions src/canister/individual_user_template/can.did
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ type PlacedBetDetail = record {
};
type Post = record {
id : nat64;
is_nsfw : bool;
status : PostStatus;
share_count : nat64;
hashtags : vec text;
Expand All @@ -143,6 +144,7 @@ type Post = record {
};
type PostDetailsForFrontend = record {
id : nat64;
is_nsfw : bool;
status : PostStatus;
home_feed_ranking_score : nat64;
hashtags : vec text;
Expand All @@ -160,6 +162,7 @@ type PostDetailsForFrontend = record {
created_by_profile_photo_url : opt text;
};
type PostDetailsFromFrontend = record {
is_nsfw : bool;
hashtags : vec text;
description : text;
video_uid : text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ mod test {
0,
Post {
id: 0,
is_nsfw: false,
description: "Singing and dancing".to_string(),
hashtags: vec!["sing".to_string(), "dance".to_string()],
video_uid: "video#0001".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ mod test {
Post::new(
0,
&PostDetailsFromFrontend {
is_nsfw: false,
description: "Doggos and puppers".into(),
hashtags: vec!["doggo".into(), "pupper".into()],
video_uid: "abcd#1234".into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ mod test {

let post_0 = Post {
id: 0,
is_nsfw: false,
description: "Singing and dancing".to_string(),
hashtags: vec!["sing".to_string(), "dance".to_string()],
video_uid: "video#0001".to_string(),
Expand Down Expand Up @@ -140,6 +141,7 @@ mod test {

let post_1 = Post {
id: 1,
is_nsfw: false,
description: "Singing and dancing".to_string(),
hashtags: vec!["sing".to_string(), "dance".to_string()],
video_uid: "video#0001".to_string(),
Expand Down Expand Up @@ -192,6 +194,7 @@ mod test {

let post_2 = Post {
id: 2,
is_nsfw: false,
description: "Singing and dancing".to_string(),
hashtags: vec!["sing".to_string(), "dance".to_string()],
video_uid: "video#0001".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ mod test {
Post::new(
0,
&PostDetailsFromFrontend {
is_nsfw: false,
description: "This is a new post".to_string(),
hashtags: vec!["#fun".to_string(), "#post".to_string()],
video_uid: "abcd1234".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fn when_backups_are_run_on_all_the_individual_user_canisters_they_capture_all_re
hashtags: vec!["alice-tag-0".to_string(), "alice-tag-1".to_string()],
video_uid: "alice-video-0".to_string(),
creator_consent_for_inclusion_in_hot_or_not: true,
is_nsfw: false
},))
.unwrap(),
)
Expand All @@ -102,6 +103,7 @@ fn when_backups_are_run_on_all_the_individual_user_canisters_they_capture_all_re
hashtags: vec!["alice-tag-2".to_string(), "alice-tag-3".to_string()],
video_uid: "alice-video-1".to_string(),
creator_consent_for_inclusion_in_hot_or_not: true,
is_nsfw: false
},))
.unwrap(),
)
Expand Down Expand Up @@ -152,6 +154,7 @@ fn when_backups_are_run_on_all_the_individual_user_canisters_they_capture_all_re
hashtags: vec!["bob-tag-0".to_string(), "bob-tag-1".to_string()],
video_uid: "bob-video-0".to_string(),
creator_consent_for_inclusion_in_hot_or_not: true,
is_nsfw: false
},))
.unwrap(),
)
Expand All @@ -167,6 +170,7 @@ fn when_backups_are_run_on_all_the_individual_user_canisters_they_capture_all_re
hashtags: vec!["bob-tag-2".to_string(), "bob-tag-3".to_string()],
video_uid: "bob-video-1".to_string(),
creator_consent_for_inclusion_in_hot_or_not: true,
is_nsfw: false
},))
.unwrap(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn when_restoring_all_data_to_an_individual_user_canister_after_backing_up_data_
hashtags: vec!["alice-tag-0".to_string(), "alice-tag-1".to_string()],
video_uid: "alice-video-0".to_string(),
creator_consent_for_inclusion_in_hot_or_not: true,
is_nsfw: false
})
.unwrap(),
)
Expand All @@ -111,6 +112,7 @@ fn when_restoring_all_data_to_an_individual_user_canister_after_backing_up_data_
hashtags: vec!["alice-tag-2".to_string(), "alice-tag-3".to_string()],
video_uid: "alice-video-1".to_string(),
creator_consent_for_inclusion_in_hot_or_not: true,
is_nsfw: false
})
.unwrap(),
)
Expand Down Expand Up @@ -161,6 +163,7 @@ fn when_restoring_all_data_to_an_individual_user_canister_after_backing_up_data_
hashtags: vec!["bob-tag-0".to_string(), "bob-tag-1".to_string()],
video_uid: "bob-video-0".to_string(),
creator_consent_for_inclusion_in_hot_or_not: true,
is_nsfw: false
})
.unwrap(),
)
Expand All @@ -176,6 +179,7 @@ fn when_restoring_all_data_to_an_individual_user_canister_after_backing_up_data_
hashtags: vec!["bob-tag-2".to_string(), "bob-tag-3".to_string()],
video_uid: "bob-video-1".to_string(),
creator_consent_for_inclusion_in_hot_or_not: true,
is_nsfw: false
})
.unwrap(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ fn when_bob_charlie_dan_interact_with_alice_created_post_then_calculated_home_fe
hashtags: vec!["fun".to_string(), "video".to_string()],
video_uid: "abcd#1234".to_string(),
creator_consent_for_inclusion_in_hot_or_not: true,
is_nsfw: false
})
.unwrap(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ fn when_bob_charlie_dan_place_bet_on_alice_created_post_then_expected_outcomes_o
"add_post_v2",
candid::encode_args((PostDetailsFromFrontend {
description: "This is a fun video to watch".to_string(),
is_nsfw: false,
hashtags: vec!["fun".to_string(), "video".to_string()],
video_uid: "abcd#1234".to_string(),
creator_consent_for_inclusion_in_hot_or_not: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ fn when_creating_a_new_post_then_post_score_should_be_calculated() {
alice_principal_id,
"add_post_v2",
candid::encode_args((PostDetailsFromFrontend {
is_nsfw: false,
description: "This is a fun video to watch".to_string(),
hashtags: vec!["fun".to_string(), "video".to_string()],
video_uid: "abcd#1234".to_string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ mod test {
let mut post = Post::new(
0,
&PostDetailsFromFrontend {
is_nsfw: false,
description: "Doggos and puppers".into(),
hashtags: vec!["doggo".into(), "pupper".into()],
video_uid: "abcd#1234".into(),
Expand Down Expand Up @@ -673,6 +674,7 @@ mod test {
let mut post = Post::new(
0,
&PostDetailsFromFrontend {
is_nsfw: false,
description: "Doggos and puppers".into(),
hashtags: vec!["doggo".into(), "pupper".into()],
video_uid: "abcd#1234".into(),
Expand Down Expand Up @@ -706,6 +708,7 @@ mod test {
let mut post = Post::new(
0,
&PostDetailsFromFrontend {
is_nsfw: false,
description: "Doggos and puppers".into(),
hashtags: vec!["doggo".into(), "pupper".into()],
video_uid: "abcd#1234".into(),
Expand Down Expand Up @@ -802,6 +805,7 @@ mod test {
let mut post = Post::new(
0,
&PostDetailsFromFrontend {
is_nsfw: false,
description: "Doggos and puppers".into(),
hashtags: vec!["doggo".into(), "pupper".into()],
video_uid: "abcd#1234".into(),
Expand Down Expand Up @@ -1116,6 +1120,7 @@ mod test {
let mut post = Post::new(
0,
&PostDetailsFromFrontend {
is_nsfw: false,
description: "Doggos and puppers".into(),
hashtags: vec!["doggo".into(), "pupper".into()],
video_uid: "abcd#1234".into(),
Expand Down Expand Up @@ -1394,6 +1399,7 @@ mod test {
let mut post = Post::new(
0,
&PostDetailsFromFrontend {
is_nsfw: false,
description: "Doggos and puppers".into(),
hashtags: vec!["doggo".into(), "pupper".into()],
video_uid: "abcd#1234".into(),
Expand Down
Loading

0 comments on commit d9e9ed4

Please sign in to comment.