mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-12 18:56:12 +00:00
Merge branch 'main' into post_mentions
This commit is contained in:
commit
6047c6b8f4
|
@ -130,6 +130,7 @@ Each Lemmy server can set its own moderation policy; appointing site-wide admins
|
|||
- [go-lemmy](https://gitea.arsenm.dev/Arsen6331/go-lemmy)
|
||||
- [Dart API client](https://github.com/LemmurOrg/lemmy_api_client)
|
||||
- [Reddit -> Lemmy Importer](https://github.com/rileynull/RedditLemmyImporter)
|
||||
- [lemmy-bot - Typescript library to make it easier to make bots for Lemmy](https://github.com/SleeplessOne1917/lemmy-bot)
|
||||
|
||||
## Support / Donate
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"eslint": "^8.25.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"jest": "^27.0.6",
|
||||
"lemmy-js-client": "0.17.2-rc.1",
|
||||
"lemmy-js-client": "0.17.2-rc.6",
|
||||
"node-fetch": "^2.6.1",
|
||||
"prettier": "^2.7.1",
|
||||
"ts-jest": "^27.0.3",
|
||||
|
|
|
@ -615,8 +615,8 @@ export async function saveUserSettingsBio(api: API): Promise<LoginResponse> {
|
|||
let form: SaveUserSettings = {
|
||||
show_nsfw: true,
|
||||
theme: "darkly",
|
||||
default_sort_type: Object.keys(SortType).indexOf(SortType.Active),
|
||||
default_listing_type: Object.keys(ListingType).indexOf(ListingType.All),
|
||||
default_sort_type: SortType.Active,
|
||||
default_listing_type: ListingType.All,
|
||||
interface_language: "en",
|
||||
show_avatars: true,
|
||||
send_notifications_to_email: false,
|
||||
|
@ -634,8 +634,8 @@ export async function saveUserSettingsFederated(
|
|||
let bio = "a changed bio";
|
||||
let form: SaveUserSettings = {
|
||||
show_nsfw: false,
|
||||
default_sort_type: Object.keys(SortType).indexOf(SortType.Hot),
|
||||
default_listing_type: Object.keys(ListingType).indexOf(ListingType.All),
|
||||
default_sort_type: SortType.Hot,
|
||||
default_listing_type: ListingType.All,
|
||||
interface_language: "",
|
||||
avatar,
|
||||
banner,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
jest.setTimeout(120000);
|
||||
import { PersonViewSafe } from "lemmy-js-client";
|
||||
import { PersonView } from "lemmy-js-client";
|
||||
|
||||
import {
|
||||
alpha,
|
||||
|
@ -25,10 +25,7 @@ beforeAll(async () => {
|
|||
|
||||
let apShortname: string;
|
||||
|
||||
function assertUserFederation(
|
||||
userOne?: PersonViewSafe,
|
||||
userTwo?: PersonViewSafe
|
||||
) {
|
||||
function assertUserFederation(userOne?: PersonView, userTwo?: PersonView) {
|
||||
expect(userOne?.person.name).toBe(userTwo?.person.name);
|
||||
expect(userOne?.person.display_name).toBe(userTwo?.person.display_name);
|
||||
expect(userOne?.person.bio).toBe(userTwo?.person.bio);
|
||||
|
|
|
@ -1134,6 +1134,13 @@ convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
|
|||
dependencies:
|
||||
safe-buffer "~5.1.1"
|
||||
|
||||
cross-fetch@^3.1.5:
|
||||
version "3.1.5"
|
||||
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f"
|
||||
integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==
|
||||
dependencies:
|
||||
node-fetch "2.6.7"
|
||||
|
||||
cross-spawn@^7.0.2, cross-spawn@^7.0.3:
|
||||
version "7.0.3"
|
||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
|
||||
|
@ -1555,6 +1562,15 @@ form-data@^3.0.0:
|
|||
combined-stream "^1.0.8"
|
||||
mime-types "^2.1.12"
|
||||
|
||||
form-data@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
|
||||
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
|
||||
dependencies:
|
||||
asynckit "^0.4.0"
|
||||
combined-stream "^1.0.8"
|
||||
mime-types "^2.1.12"
|
||||
|
||||
fs.realpath@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
||||
|
@ -2363,12 +2379,13 @@ kleur@^3.0.3:
|
|||
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
|
||||
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==
|
||||
|
||||
lemmy-js-client@0.17.2-rc.1:
|
||||
version "0.17.2-rc.1"
|
||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.2-rc.1.tgz#fe8d1508311bbf245acc98c2c3e47e2165a95b14"
|
||||
integrity sha512-YrOXuCofgkqp28krmPTQZAfUWL5zEDA0sRJ0abKcgf/I8YYkYkUkPS9TOORN5Lv3bc8RAAz4+2/zLHqYL/Tnow==
|
||||
lemmy-js-client@0.17.2-rc.6:
|
||||
version "0.17.2-rc.6"
|
||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.2-rc.6.tgz#cd488bc30edf7b65a02b91f1bc295d1b958e9b86"
|
||||
integrity sha512-/EdzpLJpYOq3ypCQA1MyI7sX0DmHUIA1ZUIda2XTCUUP7a5pltF7WHTicFrQ9j6JwCiFMTVkw6S/L8LzfD6cGA==
|
||||
dependencies:
|
||||
node-fetch "2.6.6"
|
||||
cross-fetch "^3.1.5"
|
||||
form-data "^4.0.0"
|
||||
|
||||
leven@^3.1.0:
|
||||
version "3.1.0"
|
||||
|
@ -2503,14 +2520,7 @@ natural-compare@^1.4.0:
|
|||
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
|
||||
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==
|
||||
|
||||
node-fetch@2.6.6:
|
||||
version "2.6.6"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.6.tgz#1751a7c01834e8e1697758732e9efb6eeadfaf89"
|
||||
integrity sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==
|
||||
dependencies:
|
||||
whatwg-url "^5.0.0"
|
||||
|
||||
node-fetch@^2.6.1:
|
||||
node-fetch@2.6.7, node-fetch@^2.6.1:
|
||||
version "2.6.7"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
|
||||
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
|
||||
|
|
29
crates/api/src/site/federated_instances.rs
Normal file
29
crates/api/src/site/federated_instances.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
use crate::Perform;
|
||||
use actix_web::web::Data;
|
||||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
site::{GetFederatedInstances, GetFederatedInstancesResponse},
|
||||
utils::build_federated_instances,
|
||||
};
|
||||
use lemmy_db_views::structs::SiteView;
|
||||
use lemmy_utils::{error::LemmyError, ConnectionId};
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl Perform for GetFederatedInstances {
|
||||
type Response = GetFederatedInstancesResponse;
|
||||
|
||||
#[tracing::instrument(skip(context, _websocket_id))]
|
||||
async fn perform(
|
||||
&self,
|
||||
context: &Data<LemmyContext>,
|
||||
_websocket_id: Option<ConnectionId>,
|
||||
) -> Result<Self::Response, LemmyError> {
|
||||
let site_view = SiteView::read_local(context.pool()).await?;
|
||||
let federated_instances =
|
||||
build_federated_instances(&site_view.local_site, context.pool()).await?;
|
||||
|
||||
Ok(Self::Response {
|
||||
federated_instances,
|
||||
})
|
||||
}
|
||||
}
|
|
@ -73,7 +73,6 @@ impl Perform for LeaveAdmin {
|
|||
online: 0,
|
||||
version: version::VERSION.to_string(),
|
||||
my_user: None,
|
||||
federated_instances: None,
|
||||
all_languages,
|
||||
discussion_languages,
|
||||
taglines,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
mod federated_instances;
|
||||
mod leave_admin;
|
||||
mod mod_log;
|
||||
mod purge;
|
||||
|
|
|
@ -218,13 +218,20 @@ pub struct GetSiteResponse {
|
|||
pub online: usize,
|
||||
pub version: String,
|
||||
pub my_user: Option<MyUserInfo>,
|
||||
pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
|
||||
pub all_languages: Vec<Language>,
|
||||
pub discussion_languages: Vec<LanguageId>,
|
||||
pub taglines: Vec<Tagline>,
|
||||
pub custom_emojis: Vec<CustomEmojiView>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct GetFederatedInstances {}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct GetFederatedInstancesResponse {
|
||||
pub federated_instances: Option<FederatedInstances>, // Federation may be disabled
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct MyUserInfo {
|
||||
pub local_user_view: LocalUserView,
|
||||
|
|
|
@ -94,6 +94,7 @@ pub enum UserOperation {
|
|||
PurgeCommunity,
|
||||
PurgePost,
|
||||
PurgeComment,
|
||||
GetFederatedInstances,
|
||||
}
|
||||
|
||||
#[derive(EnumString, Display, Debug, Clone)]
|
||||
|
|
|
@ -3,7 +3,7 @@ use actix_web::web::Data;
|
|||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
site::{GetSite, GetSiteResponse, MyUserInfo},
|
||||
utils::{build_federated_instances, get_local_user_settings_view_from_jwt_opt},
|
||||
utils::get_local_user_settings_view_from_jwt_opt,
|
||||
websocket::handlers::online_users::GetUsersOnline,
|
||||
};
|
||||
use lemmy_db_schema::source::{
|
||||
|
@ -84,9 +84,6 @@ impl PerformCrud for GetSite {
|
|||
None
|
||||
};
|
||||
|
||||
let federated_instances =
|
||||
build_federated_instances(&site_view.local_site, context.pool()).await?;
|
||||
|
||||
let all_languages = Language::read_all(context.pool()).await?;
|
||||
let discussion_languages = SiteLanguage::read_local_raw(context.pool()).await?;
|
||||
let taglines = Tagline::get_all(context.pool(), site_view.local_site.id).await?;
|
||||
|
@ -98,7 +95,6 @@ impl PerformCrud for GetSite {
|
|||
online,
|
||||
version: version::VERSION.to_string(),
|
||||
my_user,
|
||||
federated_instances,
|
||||
all_languages,
|
||||
discussion_languages,
|
||||
taglines,
|
||||
|
|
|
@ -93,6 +93,8 @@ use lemmy_api_common::{
|
|||
ApproveRegistrationApplication,
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetFederatedInstances,
|
||||
GetFederatedInstancesResponse,
|
||||
GetModlog,
|
||||
GetModlogResponse,
|
||||
GetSite,
|
||||
|
@ -373,3 +375,7 @@ impl SendActivity for EditCustomEmoji {
|
|||
impl SendActivity for DeleteCustomEmoji {
|
||||
type Response = DeleteCustomEmojiResponse;
|
||||
}
|
||||
|
||||
impl SendActivity for GetFederatedInstances {
|
||||
type Response = GetFederatedInstancesResponse;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ services:
|
|||
# run docker compose up --build
|
||||
# assuming lemmy-ui is cloned besides lemmy directory
|
||||
# build:
|
||||
# context: ../../../lemmy-ui
|
||||
# context: ../../lemmy-ui
|
||||
# dockerfile: dev.dockerfile
|
||||
networks:
|
||||
- lemmyinternal
|
||||
|
|
|
@ -86,6 +86,7 @@ use lemmy_api_common::{
|
|||
ApproveRegistrationApplication,
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetFederatedInstances,
|
||||
GetModlog,
|
||||
GetSite,
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
|
@ -165,6 +166,11 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
|||
.route("/join", web::post().to(route_post::<CommunityJoin>))
|
||||
.route("/mod/join", web::post().to(route_post::<ModJoin>)),
|
||||
)
|
||||
.service(
|
||||
web::scope("/federated_instances")
|
||||
.wrap(rate_limit.message())
|
||||
.route("", web::get().to(route_get::<GetFederatedInstances>)),
|
||||
)
|
||||
// Post
|
||||
.service(
|
||||
// Handle POST to /post separately to add the post() rate limitter
|
||||
|
|
|
@ -98,6 +98,7 @@ use lemmy_api_common::{
|
|||
ApproveRegistrationApplication,
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetFederatedInstances,
|
||||
GetModlog,
|
||||
GetSite,
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
|
@ -640,6 +641,9 @@ pub async fn match_websocket_operation(
|
|||
do_websocket_operation::<TransferCommunity>(context, id, op, data).await
|
||||
}
|
||||
UserOperation::LeaveAdmin => do_websocket_operation::<LeaveAdmin>(context, id, op, data).await,
|
||||
UserOperation::GetFederatedInstances => {
|
||||
do_websocket_operation::<GetFederatedInstances>(context, id, op, data).await
|
||||
}
|
||||
|
||||
// Community ops
|
||||
UserOperation::FollowCommunity => {
|
||||
|
|
Loading…
Reference in a new issue