turn this on as our mailchimp webhook server
@@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize};
use cio_api::db::Database;
use cio_api::mailing_list::MailchimpWebhook;
use cio_api::models::{GitHubUser, GithubRepo, NewRFD};
-//use cio_api::slack::{get_public_relations_channel_post_url, post_to_channel};
+use cio_api::slack::{get_public_relations_channel_post_url, post_to_channel};
use cio_api::utils::{authenticate_github_jwt, get_gsuite_token, github_org};
#[tokio::main]
@@ -495,7 +495,7 @@ async fn ping_mailchimp_webhooks(_rqctx: Arc<RequestContext>) -> Result<HttpResp
}]
async fn listen_mailchimp_webhooks(_rqctx: Arc<RequestContext>, query_args: Query<MailchimpWebhook>) -> Result<HttpResponseAccepted<String>, HttpError> {
// TODO: share the database connection in the context.
- //let db = Database::new();
+ let db = Database::new();
let event = query_args.into_inner();
@@ -508,22 +508,18 @@ async fn listen_mailchimp_webhooks(_rqctx: Arc<RequestContext>, query_args: Quer
}
// Parse the webhook as a new mailing list subscriber.
- /*let new_subscriber = event.as_subscriber();
+ let new_subscriber = event.as_subscriber();
- // TODO: Update the subscriber in the database.
+ // Update the subscriber in the database.
let subscriber = db.upsert_mailing_list_subscriber(&new_subscriber);
- // TODO: Update airtable with the new subscriber.
+ // Update airtable with the new subscriber.
let mut airtable_subscriber = subscriber.clone();
airtable_subscriber.create_or_update_in_airtable().await;
// Parse the signup into a slack message.
// Send the message to the slack channel.
- post_to_channel(
- get_public_relations_channel_post_url(),
- new_subscriber.as_slack_msg(),
- )
- .await;*/
+ post_to_channel(get_public_relations_channel_post_url(), new_subscriber.as_slack_msg()).await;
Ok(HttpResponseAccepted("Updated successfully".to_string()))
}
