refactor(domain): remove public_key/private_key from User model — managed by federation adapter
This commit is contained in:
@@ -58,8 +58,6 @@ struct FeedRow {
|
||||
author_local: bool,
|
||||
u_ap_id: Option<String>,
|
||||
inbox_url: Option<String>,
|
||||
public_key: Option<String>,
|
||||
private_key: Option<String>,
|
||||
author_created_at: DateTime<Utc>,
|
||||
author_updated_at: DateTime<Utc>,
|
||||
like_count: i64,
|
||||
@@ -76,7 +74,6 @@ const FEED_SELECT: &str = "
|
||||
u.id AS author_id, u.username, u.email, u.password_hash,
|
||||
u.display_name, u.bio, u.avatar_url, u.header_url, u.custom_css,
|
||||
u.local AS author_local, u.ap_id AS u_ap_id, u.inbox_url,
|
||||
u.public_key, u.private_key,
|
||||
u.created_at AS author_created_at, u.updated_at AS author_updated_at,
|
||||
(SELECT COUNT(*) FROM likes l WHERE l.thought_id=t.id) AS like_count,
|
||||
(SELECT COUNT(*) FROM boosts b WHERE b.thought_id=t.id) AS boost_count,
|
||||
@@ -111,8 +108,6 @@ fn row_to_entry(r: FeedRow) -> FeedEntry {
|
||||
local: r.author_local,
|
||||
ap_id: r.u_ap_id,
|
||||
inbox_url: r.inbox_url,
|
||||
public_key: r.public_key,
|
||||
private_key: r.private_key,
|
||||
created_at: r.author_created_at,
|
||||
updated_at: r.author_updated_at,
|
||||
};
|
||||
@@ -141,8 +136,6 @@ struct UserRow {
|
||||
local: bool,
|
||||
ap_id: Option<String>,
|
||||
inbox_url: Option<String>,
|
||||
public_key: Option<String>,
|
||||
private_key: Option<String>,
|
||||
created_at: DateTime<Utc>,
|
||||
updated_at: DateTime<Utc>,
|
||||
}
|
||||
@@ -162,8 +155,6 @@ impl From<UserRow> for User {
|
||||
local: r.local,
|
||||
ap_id: r.ap_id,
|
||||
inbox_url: r.inbox_url,
|
||||
public_key: r.public_key,
|
||||
private_key: r.private_key,
|
||||
created_at: r.created_at,
|
||||
updated_at: r.updated_at,
|
||||
}
|
||||
@@ -172,7 +163,7 @@ impl From<UserRow> for User {
|
||||
|
||||
const USER_SELECT: &str =
|
||||
"SELECT id,username,email,password_hash,display_name,bio,avatar_url,header_url,\
|
||||
custom_css,local,ap_id,inbox_url,public_key,private_key,created_at,updated_at FROM users";
|
||||
custom_css,local,ap_id,inbox_url,created_at,updated_at FROM users";
|
||||
|
||||
#[async_trait]
|
||||
impl SearchPort for PgSearchRepository {
|
||||
|
||||
@@ -58,8 +58,6 @@ struct FeedRow {
|
||||
author_local: bool,
|
||||
u_ap_id: Option<String>,
|
||||
inbox_url: Option<String>,
|
||||
public_key: Option<String>,
|
||||
private_key: Option<String>,
|
||||
author_created_at: DateTime<Utc>,
|
||||
author_updated_at: DateTime<Utc>,
|
||||
like_count: i64,
|
||||
@@ -87,7 +85,6 @@ fn feed_select(viewer: Option<uuid::Uuid>) -> String {
|
||||
u.id AS author_id, u.username, u.email, u.password_hash,
|
||||
u.display_name, u.bio, u.avatar_url, u.header_url, u.custom_css,
|
||||
u.local AS author_local, u.ap_id AS u_ap_id, u.inbox_url,
|
||||
u.public_key, u.private_key,
|
||||
u.created_at AS author_created_at, u.updated_at AS author_updated_at,
|
||||
(SELECT COUNT(*) FROM likes l WHERE l.thought_id=t.id) AS like_count,
|
||||
(SELECT COUNT(*) FROM boosts b WHERE b.thought_id=t.id) AS boost_count,
|
||||
@@ -125,8 +122,6 @@ fn row_to_entry(r: FeedRow) -> FeedEntry {
|
||||
local: r.author_local,
|
||||
ap_id: r.u_ap_id,
|
||||
inbox_url: r.inbox_url,
|
||||
public_key: r.public_key,
|
||||
private_key: r.private_key,
|
||||
created_at: r.author_created_at,
|
||||
updated_at: r.author_updated_at,
|
||||
};
|
||||
|
||||
@@ -132,7 +132,7 @@ impl FollowRepository for PgFollowRepository {
|
||||
.map_err(|e| DomainError::Internal(e.to_string()))?;
|
||||
|
||||
let rows = sqlx::query_as::<_, crate::user::UserRow>(
|
||||
"SELECT u.id,u.username,u.email,u.password_hash,u.display_name,u.bio,u.avatar_url,u.header_url,u.custom_css,u.local,u.ap_id,u.inbox_url,u.public_key,u.private_key,u.created_at,u.updated_at
|
||||
"SELECT u.id,u.username,u.email,u.password_hash,u.display_name,u.bio,u.avatar_url,u.header_url,u.custom_css,u.local,u.ap_id,u.inbox_url,u.created_at,u.updated_at
|
||||
FROM users u JOIN follows f ON f.follower_id=u.id
|
||||
WHERE f.following_id=$1 AND f.state='accepted'
|
||||
ORDER BY f.created_at DESC LIMIT $2 OFFSET $3"
|
||||
@@ -166,7 +166,7 @@ impl FollowRepository for PgFollowRepository {
|
||||
.map_err(|e| DomainError::Internal(e.to_string()))?;
|
||||
|
||||
let rows = sqlx::query_as::<_, crate::user::UserRow>(
|
||||
"SELECT u.id,u.username,u.email,u.password_hash,u.display_name,u.bio,u.avatar_url,u.header_url,u.custom_css,u.local,u.ap_id,u.inbox_url,u.public_key,u.private_key,u.created_at,u.updated_at
|
||||
"SELECT u.id,u.username,u.email,u.password_hash,u.display_name,u.bio,u.avatar_url,u.header_url,u.custom_css,u.local,u.ap_id,u.inbox_url,u.created_at,u.updated_at
|
||||
FROM users u JOIN follows f ON f.following_id=u.id
|
||||
WHERE f.follower_id=$1 AND f.state='accepted'
|
||||
ORDER BY f.created_at DESC LIMIT $2 OFFSET $3"
|
||||
|
||||
@@ -65,8 +65,6 @@ impl TopFriendRepository for PgTopFriendRepository {
|
||||
local: bool,
|
||||
ap_id: Option<String>,
|
||||
inbox_url: Option<String>,
|
||||
public_key: Option<String>,
|
||||
private_key: Option<String>,
|
||||
created_at: chrono::DateTime<chrono::Utc>,
|
||||
updated_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
@@ -74,7 +72,7 @@ impl TopFriendRepository for PgTopFriendRepository {
|
||||
"SELECT tf.user_id AS tf_user_id, tf.friend_id, tf.position,
|
||||
u.id, u.username, u.email, u.password_hash, u.display_name, u.bio,
|
||||
u.avatar_url, u.header_url, u.custom_css, u.local, u.ap_id, u.inbox_url,
|
||||
u.public_key, u.private_key, u.created_at, u.updated_at
|
||||
u.created_at, u.updated_at
|
||||
FROM top_friends tf JOIN users u ON u.id=tf.friend_id
|
||||
WHERE tf.user_id=$1 ORDER BY tf.position",
|
||||
)
|
||||
@@ -105,8 +103,6 @@ impl TopFriendRepository for PgTopFriendRepository {
|
||||
local: r.local,
|
||||
ap_id: r.ap_id,
|
||||
inbox_url: r.inbox_url,
|
||||
public_key: r.public_key,
|
||||
private_key: r.private_key,
|
||||
created_at: r.created_at,
|
||||
updated_at: r.updated_at,
|
||||
};
|
||||
|
||||
@@ -31,8 +31,6 @@ pub(crate) struct UserRow {
|
||||
pub local: bool,
|
||||
pub ap_id: Option<String>,
|
||||
pub inbox_url: Option<String>,
|
||||
pub public_key: Option<String>,
|
||||
pub private_key: Option<String>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
@@ -52,15 +50,13 @@ impl From<UserRow> for User {
|
||||
local: r.local,
|
||||
ap_id: r.ap_id,
|
||||
inbox_url: r.inbox_url,
|
||||
public_key: r.public_key,
|
||||
private_key: r.private_key,
|
||||
created_at: r.created_at,
|
||||
updated_at: r.updated_at,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const USER_SELECT: &str = "SELECT id,username,email,password_hash,display_name,bio,avatar_url,header_url,custom_css,local,ap_id,inbox_url,public_key,private_key,created_at,updated_at FROM users";
|
||||
const USER_SELECT: &str = "SELECT id,username,email,password_hash,display_name,bio,avatar_url,header_url,custom_css,local,ap_id,inbox_url,created_at,updated_at FROM users";
|
||||
|
||||
#[async_trait]
|
||||
impl UserRepository for PgUserRepository {
|
||||
@@ -93,15 +89,14 @@ impl UserRepository for PgUserRepository {
|
||||
|
||||
async fn save(&self, user: &User) -> Result<(), DomainError> {
|
||||
sqlx::query(
|
||||
"INSERT INTO users (id,username,email,password_hash,display_name,bio,avatar_url,header_url,custom_css,local,ap_id,inbox_url,public_key,private_key,created_at,updated_at)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16)
|
||||
"INSERT INTO users (id,username,email,password_hash,display_name,bio,avatar_url,header_url,custom_css,local,ap_id,inbox_url,created_at,updated_at)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14)
|
||||
ON CONFLICT(id) DO UPDATE SET
|
||||
username=EXCLUDED.username, email=EXCLUDED.email,
|
||||
password_hash=EXCLUDED.password_hash, display_name=EXCLUDED.display_name,
|
||||
bio=EXCLUDED.bio, avatar_url=EXCLUDED.avatar_url,
|
||||
header_url=EXCLUDED.header_url, custom_css=EXCLUDED.custom_css,
|
||||
local=EXCLUDED.local, ap_id=EXCLUDED.ap_id, inbox_url=EXCLUDED.inbox_url,
|
||||
public_key=EXCLUDED.public_key, private_key=EXCLUDED.private_key,
|
||||
updated_at=NOW()"
|
||||
)
|
||||
.bind(user.id.as_uuid())
|
||||
@@ -116,8 +111,6 @@ impl UserRepository for PgUserRepository {
|
||||
.bind(user.local)
|
||||
.bind(&user.ap_id)
|
||||
.bind(&user.inbox_url)
|
||||
.bind(&user.public_key)
|
||||
.bind(&user.private_key)
|
||||
.bind(user.created_at)
|
||||
.bind(user.updated_at)
|
||||
.execute(&self.pool)
|
||||
|
||||
@@ -15,8 +15,6 @@ pub struct User {
|
||||
pub local: bool,
|
||||
pub ap_id: Option<String>,
|
||||
pub inbox_url: Option<String>,
|
||||
pub public_key: Option<String>,
|
||||
pub private_key: Option<String>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
@@ -42,8 +40,6 @@ impl User {
|
||||
local: true,
|
||||
ap_id: None,
|
||||
inbox_url: None,
|
||||
public_key: None,
|
||||
private_key: None,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
}
|
||||
|
||||
@@ -771,8 +771,6 @@ impl ActivityPubRepository for TestStore {
|
||||
local: false,
|
||||
ap_id: Some(actor_ap_url.to_string()),
|
||||
inbox_url: None,
|
||||
public_key: None,
|
||||
private_key: None,
|
||||
created_at: chrono::Utc::now(),
|
||||
updated_at: chrono::Utc::now(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user