Merge pull request 'Fix #890 Fix interact URI used from remote account to remote account' (#898) from remote-follow-from-remote into main

Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/898
This commit is contained in:
KitaitiMakoto 2021-02-14 14:40:25 +00:00
commit 73e075e216
2 changed files with 11 additions and 11 deletions

View file

@ -832,11 +832,7 @@ impl User {
pub fn webfinger(&self, conn: &Connection) -> Result<Webfinger> { pub fn webfinger(&self, conn: &Connection) -> Result<Webfinger> {
Ok(Webfinger { Ok(Webfinger {
subject: format!( subject: format!("acct:{}", self.acct_authority(conn)?),
"acct:{}@{}",
self.username,
self.get_instance(conn)?.public_domain
),
aliases: vec![self.ap_url.clone()], aliases: vec![self.ap_url.clone()],
links: vec![ links: vec![
Link { Link {
@ -874,6 +870,14 @@ impl User {
}) })
} }
pub fn acct_authority(&self, conn: &Connection) -> Result<String> {
Ok(format!(
"{}@{}",
self.username,
self.get_instance(conn)?.public_domain
))
}
pub fn set_avatar(&self, conn: &Connection, id: i32) -> Result<()> { pub fn set_avatar(&self, conn: &Connection, id: i32) -> Result<()> {
diesel::update(self) diesel::update(self)
.set(users::avatar_id.eq(id)) .set(users::avatar_id.eq(id))

View file

@ -1,7 +1,7 @@
use activitypub::collection::{OrderedCollection, OrderedCollectionPage}; use activitypub::collection::{OrderedCollection, OrderedCollectionPage};
use diesel::SaveChangesDsl; use diesel::SaveChangesDsl;
use rocket::{ use rocket::{
http::{ContentType, Cookies}, http::{uri::Uri, ContentType, Cookies},
request::LenientForm, request::LenientForm,
response::{status, Content, Flash, Redirect}, response::{status, Content, Flash, Redirect},
}; };
@ -137,11 +137,7 @@ pub fn follow_not_connected(
.and_then(|uri| { .and_then(|uri| {
Some(uri.replace( Some(uri.replace(
"{uri}", "{uri}",
&format!( &Uri::percent_encode(&target.acct_authority(&conn).ok()?),
"{}@{}",
target.fqn,
target.get_instance(&conn).ok()?.public_domain
),
)) ))
}) })
{ {