From 6401cb6fb7ae95cfa4673cc87cc55f93ecd52ed1 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 1 Feb 2021 00:48:22 +0900 Subject: [PATCH] Define User::remote_user_found() and publish_remote_user_found() --- plume-models/src/users.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index 52ae57ef..0b7cf3af 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -1,8 +1,8 @@ use crate::{ ap_url, blocklisted_emails::BlocklistedEmail, blogs::Blog, db_conn::DbConn, follows::Follow, instance::*, medias::Media, notifications::Notification, post_authors::PostAuthor, posts::Post, - safe_string::SafeString, schema::users, timeline::Timeline, Connection, Error, Result, CONFIG, - ITEMS_PER_PAGE, + safe_string::SafeString, schema::users, timeline::Timeline, Connection, Error, Result, + UserEvent::*, CONFIG, ITEMS_PER_PAGE, USER_CHAN, }; use activitypub::{ activity::Delete, @@ -33,6 +33,7 @@ use reqwest::{ header::{HeaderValue, ACCEPT}, ClientBuilder, }; +use riker::actors::{Publish, Tell}; use rocket::{ outcome::IntoOutcome, request::{self, FromRequest, Request}, @@ -892,6 +893,21 @@ impl User { self.fqn.clone() } } + + pub fn remote_user_found(&self) { + tracing::trace!("{:?}", self); + self.publish_remote_user_found(); + } + + fn publish_remote_user_found(&self) { + USER_CHAN.tell( + Publish { + msg: RemoteUserFound(Arc::new(self.clone())), + topic: "user.remote_user_found".into(), + }, + None, + ) + } } impl<'a, 'r> FromRequest<'a, 'r> for User {