-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report btn #241
Report btn #241
Changes from all commits
10c3156
a28ac46
1bd7fcc
13f6239
19e3fed
048cfbe
3bef0b4
d1537ab
375b8ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use leptos::*; | ||
|
||
#[component] | ||
pub fn SelectOption(#[prop(into)] is: String, value: ReadSignal<String>) -> impl IntoView { | ||
let is_copy = is.clone(); | ||
|
||
view! { | ||
<option | ||
value=is.clone() | ||
selected=move || value() == is_copy | ||
> | ||
{is} | ||
</option> | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
use std::{env, fmt::Display}; | ||
|
||
use leptos::{expect_context, server, ServerFnError}; | ||
|
||
pub enum ReportOption { | ||
Nudity, | ||
Violence, | ||
Offensive, | ||
Spam, | ||
Other, | ||
} | ||
|
||
impl ReportOption { | ||
pub fn as_str(&self) -> impl Display { | ||
match self { | ||
ReportOption::Nudity => "Nudity/Porn", | ||
ReportOption::Violence => "Violence/Gore", | ||
ReportOption::Offensive => "Offensive", | ||
ReportOption::Spam => "Spam/Ad", | ||
ReportOption::Other => "Others", | ||
} | ||
} | ||
} | ||
|
||
#[cfg(feature = "ga4")] | ||
#[server] | ||
pub async fn send_report_offchain( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also add a mock (or make reporting no-op locally) |
||
reporter_id: String, | ||
publisher_id: String, | ||
publisher_canister_id: String, | ||
post_id: String, | ||
video_id: String, | ||
reason: String, | ||
video_url: String, | ||
) -> Result<(), ServerFnError> { | ||
use crate::utils::off_chain; | ||
use tonic::metadata::MetadataValue; | ||
use tonic::transport::Channel; | ||
use tonic::Request; | ||
|
||
let channel: Channel = expect_context(); | ||
|
||
let mut off_chain_agent_grpc_auth_token = env::var("GRPC_AUTH_TOKEN").expect("GRPC_AUTH_TOKEN"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we migrate off chain client to AppState instead of constructing every time? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
// removing whitespaces and new lines for proper parsing | ||
off_chain_agent_grpc_auth_token.retain(|c| !c.is_whitespace()); | ||
|
||
let token: MetadataValue<_> = format!("Bearer {}", off_chain_agent_grpc_auth_token).parse()?; | ||
|
||
let mut client = off_chain::off_chain_client::OffChainClient::with_interceptor( | ||
channel, | ||
move |mut req: Request<()>| { | ||
req.metadata_mut().insert("authorization", token.clone()); | ||
Ok(req) | ||
}, | ||
); | ||
|
||
let request = tonic::Request::new(off_chain::ReportPostRequest { | ||
reporter_id, | ||
publisher_id, | ||
publisher_canister_id, | ||
post_id, | ||
video_id, | ||
reason, | ||
video_url, | ||
}); | ||
|
||
client.report_post(request).await?; | ||
|
||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ga4
feature flag