Send AddPerson() activity when subscription payment is detected
This commit is contained in:
parent
acdb51e6f4
commit
0f5a2edf7f
2 changed files with 25 additions and 3 deletions
|
@ -10,7 +10,9 @@ use web3::{
|
|||
types::{BlockId, BlockNumber, FilterBuilder, U256},
|
||||
};
|
||||
|
||||
use crate::config::BlockchainConfig;
|
||||
use crate::activitypub::builders::add_person::prepare_add_person;
|
||||
use crate::activitypub::identifiers::LocalActorCollection;
|
||||
use crate::config::{BlockchainConfig, Instance};
|
||||
use crate::database::{Pool, get_database_client};
|
||||
use crate::errors::{ConversionError, DatabaseError};
|
||||
use crate::models::notifications::queries::{
|
||||
|
@ -52,6 +54,7 @@ fn u256_to_date(value: U256) -> Result<DateTime<Utc>, ConversionError> {
|
|||
|
||||
/// Search for subscription update events
|
||||
pub async fn check_subscriptions(
|
||||
instance: &Instance,
|
||||
web3: &Web3<Http>,
|
||||
contract: &Contract<Http>,
|
||||
sync_state: &mut SyncState,
|
||||
|
@ -161,6 +164,14 @@ pub async fn check_subscriptions(
|
|||
&subscription.sender_id,
|
||||
&subscription.recipient_id,
|
||||
).await?;
|
||||
if let Some(ref remote_sender) = sender.actor_json {
|
||||
prepare_add_person(
|
||||
instance,
|
||||
&recipient,
|
||||
remote_sender,
|
||||
LocalActorCollection::Subscribers,
|
||||
).spawn_deliver();
|
||||
};
|
||||
};
|
||||
};
|
||||
},
|
||||
|
@ -184,6 +195,14 @@ pub async fn check_subscriptions(
|
|||
&sender.id,
|
||||
&recipient.id,
|
||||
).await?;
|
||||
if let Some(ref remote_sender) = sender.actor_json {
|
||||
prepare_add_person(
|
||||
instance,
|
||||
&recipient,
|
||||
remote_sender,
|
||||
LocalActorCollection::Subscribers,
|
||||
).spawn_deliver();
|
||||
};
|
||||
},
|
||||
Err(other_error) => return Err(other_error.into()),
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ use anyhow::Error;
|
|||
use chrono::{DateTime, Utc};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::config::{Config, Instance};
|
||||
use crate::database::Pool;
|
||||
use crate::ethereum::contracts::Blockchain;
|
||||
use crate::ethereum::nft::process_nft_events;
|
||||
|
@ -61,6 +61,7 @@ async fn nft_monitor_task(
|
|||
}
|
||||
|
||||
async fn subscription_monitor_task(
|
||||
instance: &Instance,
|
||||
maybe_blockchain: Option<&mut Blockchain>,
|
||||
db_pool: &Pool,
|
||||
) -> Result<(), Error> {
|
||||
|
@ -73,6 +74,7 @@ async fn subscription_monitor_task(
|
|||
None => return Ok(()), // feature not enabled
|
||||
};
|
||||
check_subscriptions(
|
||||
instance,
|
||||
&blockchain.contract_set.web3,
|
||||
subscription,
|
||||
&mut blockchain.sync_state,
|
||||
|
@ -81,7 +83,7 @@ async fn subscription_monitor_task(
|
|||
}
|
||||
|
||||
pub fn run(
|
||||
_config: Config,
|
||||
config: Config,
|
||||
mut maybe_blockchain: Option<Blockchain>,
|
||||
db_pool: Pool,
|
||||
) -> () {
|
||||
|
@ -109,6 +111,7 @@ pub fn run(
|
|||
},
|
||||
Task::SubscriptionMonitor => {
|
||||
subscription_monitor_task(
|
||||
&config.instance(),
|
||||
maybe_blockchain.as_mut(),
|
||||
&db_pool,
|
||||
).await
|
||||
|
|
Loading…
Reference in a new issue