Add intercom functionality for setting factory thumbnails

This commit is contained in:
NG (Graham) committed 2025-12-13 16:23:18 -05:00
1 parent aedec62b8d
commit f6f6e1f127
17 files changed
+96 -36

No files matched your search

+15
View File
@@ -53,6 +53,21 @@ impl super::IntercomUser for super::account_json::UserData {
Ok(())
}
async fn save_factory_thumbnail(&self, factory_id: i32, image: Vec<u8>) -> Result<(), polariton_server::operations::SimpleOpError> {
let token = generate_token(factory_id.to_string().as_bytes(), &self.secret);
let auth_header_val = format!("Internal {}", token);
let url = format!("{}/roboshop/Live/{}", self.cdn, factory_id);
if let Err(e) = self.http_client.post(url)
.header("Authorization", auth_header_val)
.body(image)
.send()
.await {
log::error!("Failed to update factory thumbnail for {} ({}): {}", self.account.public_id, self.account.id, e);
return Err((crate::data::error_codes::WebServicesError::UnexpectedError as i16).into());
}
Ok(())
}
async fn webservice_listener(&self) -> Result<super::IntercomListener<IntercomWebServiceUserMessage>, polariton_server::operations::SimpleOpError> {
self.listen_on_websocket(".oj_services").await
.map_err(|e| polariton_server::operations::SimpleOpError::with_message(