.slur_filter_regex(diesel_option_overwrite(&data.slur_filter_regex))
.actor_name_max_length(data.actor_name_max_length)
.federation_enabled(data.federation_enabled)
- .federation_debug(data.federation_debug)
.federation_worker_count(data.federation_worker_count)
.captcha_enabled(data.captcha_enabled)
.captcha_difficulty(data.captcha_difficulty.clone())
.slur_filter_regex(diesel_option_overwrite(&data.slur_filter_regex))
.actor_name_max_length(data.actor_name_max_length)
.federation_enabled(data.federation_enabled)
- .federation_debug(data.federation_debug)
.federation_worker_count(data.federation_worker_count)
.captcha_enabled(data.captcha_enabled)
.captcha_difficulty(data.captcha_difficulty.clone())
"mediaType": "text/markdown"
},
"sensitive": false,
- "moderators": "http://enterprise.lemmy.ml/c/main/moderators",
"postingRestrictedToMods": false,
"inbox": "http://enterprise.lemmy.ml/c/main/inbox",
"outbox": "http://enterprise.lemmy.ml/c/main/outbox",
"followers": "http://enterprise.lemmy.ml/c/main/followers",
+ "attributedTo": "https://enterprise.lemmy.ml/c/main/moderators",
"endpoints": {
"sharedInbox": "http://enterprise.lemmy.ml/inbox"
},
],
"commentsEnabled": true,
"sensitive": false,
- "stickied": false,
"language": {
"identifier": "ko",
"name": "한국어"
],
"commentsEnabled": true,
"sensitive": false,
- "stickied": false,
"published": "2021-10-29T15:10:51.557399+00:00",
"updated": "2021-10-29T15:11:35.976374+00:00"
},
"attachment": [],
"commentsEnabled": true,
"sensitive": false,
- "stickied": true,
"published": "2023-02-06T06:42:41.939437+00:00",
"language": {
"identifier": "de",
"attachment": [],
"commentsEnabled": true,
"sensitive": false,
- "stickied": true,
"published": "2023-02-06T06:42:37.119567+00:00",
"language": {
"identifier": "de",
},
"inbox": "https://enterprise.lemmy.ml/c/tenforward/inbox",
"followers": "https://enterprise.lemmy.ml/c/tenforward/followers",
- "moderators": "https://enterprise.lemmy.ml/c/tenforward/moderators",
"attributedTo": "https://enterprise.lemmy.ml/c/tenforward/moderators",
"featured": "https://enterprise.lemmy.ml/c/tenforward//featured",
"postingRestrictedToMods": false,
},
"sensitive": false,
"commentsEnabled": true,
- "stickied": true,
"language": {
"identifier": "fr",
"name": "Français"
insert_activity,
objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
protocol::{
- activities::{
- community::{collection_add::CollectionAdd, collection_remove::CollectionRemove},
- create_or_update::page::CreateOrUpdatePage,
- CreateOrUpdateType,
- },
+ activities::community::{collection_add::CollectionAdd, collection_remove::CollectionRemove},
InCommunity,
},
SendActivity,
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
- // Deprecated, for backwards compatibility with 0.17
- CreateOrUpdatePage::send(
- &response.post_view.post,
- local_user_view.person.id,
- CreateOrUpdateType::Update,
- context,
- )
- .await?;
let community = Community::read(context.pool(), response.post_view.community.id)
.await?
.into();
activity_lists::AnnouncableActivities,
insert_activity,
protocol::{
- activities::{
- community::lock_page::{LockPage, LockType, UndoLockPage},
- create_or_update::page::CreateOrUpdatePage,
- CreateOrUpdateType,
- },
+ activities::community::lock_page::{LockPage, LockType, UndoLockPage},
InCommunity,
},
SendActivity,
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
- // For backwards compat with 0.17
- CreateOrUpdatePage::send(
- &response.post_view.post,
- local_user_view.person.id,
- CreateOrUpdateType::Update,
- context,
- )
- .await?;
let id = generate_activity_id(
LockType::Lock,
&context.settings().get_protocol_and_hostname(),
CreateOrUpdateType::Create => {
verify_domains_match(self.actor.inner(), self.object.id.inner())?;
verify_urls_match(self.actor.inner(), self.object.creator()?.inner())?;
- // Check that the post isnt locked or stickied, as that isnt possible for newly created posts.
+ // Check that the post isnt locked, as that isnt possible for newly created posts.
// However, when fetching a remote post we generate a new create activity with the current
- // locked/stickied value, so this check may fail. So only check if its a local community,
+ // locked value, so this check may fail. So only check if its a local community,
// because then we will definitely receive all create and update activities separately.
- let is_featured_or_locked =
- self.object.stickied == Some(true) || self.object.comments_enabled == Some(false);
- if community.local && is_featured_or_locked {
- return Err(LemmyError::from_message(
- "New post cannot be stickied or locked",
- ));
+ let is_locked = self.object.comments_enabled == Some(false);
+ if community.local && is_locked {
+ return Err(LemmyError::from_message("New post cannot be locked"));
}
}
CreateOrUpdateType::Update => {
icon: self.icon.clone().map(ImageObject::new),
image: self.banner.clone().map(ImageObject::new),
sensitive: Some(self.nsfw),
- moderators: Some(generate_moderators_url(&self.actor_id)?.into()),
featured: Some(generate_featured_url(&self.actor_id)?.into()),
inbox: self.inbox_url.clone().into(),
outbox: generate_outbox_url(&self.actor_id)?.into(),
.map_err(|e| debug!("{}", e))
.ok();
- if let Some(moderators) = group.attributed_to.or(group.moderators) {
+ if let Some(moderators) = group.attributed_to {
moderators
.dereference(&community, context)
.await
let context2 = context.reset_request_count();
let mut json: Group = file_to_json_object("assets/lemmy/objects/group.json").unwrap();
// change these links so they dont fetch over the network
- json.moderators = None;
json.attributed_to = None;
json.outbox =
CollectionId::parse("https://enterprise.lemmy.ml/c/tenforward/not_outbox").unwrap();
source::{
community::Community,
local_site::LocalSite,
- moderator::{ModFeaturePost, ModFeaturePostForm, ModLockPost, ModLockPostForm},
+ moderator::{ModLockPost, ModLockPostForm},
person::Person,
post::{Post, PostInsertForm, PostUpdateForm},
},
image: self.thumbnail_url.clone().map(ImageObject::new),
comments_enabled: Some(!self.locked),
sensitive: Some(self.nsfw),
- stickied: Some(self.featured_community),
language,
published: Some(convert_datetime(self.published)),
updated: self.updated.map(convert_datetime),
ap_id: Some(page.id.clone().into()),
local: Some(false),
language_id,
- featured_community: page.stickied,
+ featured_community: None,
featured_local: None,
}
} else {
.community_id(community.id)
.ap_id(Some(page.id.clone().into()))
.locked(page.comments_enabled.map(|e| !e))
- .featured_community(page.stickied)
.updated(page.updated.map(|u| u.naive_local()))
.build()
};
let post = Post::create(context.pool(), &form).await?;
- // write mod log entries for feature/lock
- if Page::is_featured_changed(&old_post, &page.stickied) {
- let form = ModFeaturePostForm {
- mod_person_id: creator.id,
- post_id: post.id,
- featured: post.featured_community,
- is_featured_community: true,
- };
- ModFeaturePost::create(context.pool(), &form).await?;
- }
+ // write mod log entry for lock
if Page::is_locked_changed(&old_post, &page.comments_enabled) {
let form = ModLockPostForm {
mod_person_id: creator.id,
assert!(post.body.is_some());
assert_eq!(post.body.as_ref().unwrap().len(), 45);
assert!(!post.locked);
- assert!(post.featured_community);
+ assert!(!post.featured_community);
assert_eq!(context.request_count(), 0);
Post::delete(context.pool(), post.id).await.unwrap();
pub(crate) image: Option<ImageObject>,
// lemmy extension
pub(crate) sensitive: Option<bool>,
- // deprecated, use attributed_to instead
- pub(crate) moderators: Option<CollectionId<ApubCommunityModerators>>,
#[serde(deserialize_with = "deserialize_skip_error", default)]
pub(crate) attributed_to: Option<CollectionId<ApubCommunityModerators>>,
// lemmy extension
followers_url: Some(self.followers.into()),
inbox_url: Some(self.inbox.into()),
shared_inbox_url: self.endpoints.map(|e| e.shared_inbox.into()),
- moderators_url: self.moderators.map(Into::into),
+ moderators_url: self.attributed_to.map(Into::into),
posting_restricted_to_mods: self.posting_restricted_to_mods,
instance_id,
featured_url: self.featured.map(Into::into),
followers_url: Some(self.followers.into()),
inbox_url: Some(self.inbox.into()),
shared_inbox_url: Some(self.endpoints.map(|e| e.shared_inbox.into())),
- moderators_url: self.moderators.map(Into::into),
+ moderators_url: self.attributed_to.map(Into::into),
posting_restricted_to_mods: self.posting_restricted_to_mods,
featured_url: self.featured.map(Into::into),
}
pub(crate) image: Option<ImageObject>,
pub(crate) comments_enabled: Option<bool>,
pub(crate) sensitive: Option<bool>,
- /// Deprecated, for compatibility with Lemmy 0.17
- pub(crate) stickied: Option<bool>,
pub(crate) published: Option<DateTime<FixedOffset>>,
pub(crate) updated: Option<DateTime<FixedOffset>>,
pub(crate) language: Option<LanguageTag>,
}
impl Page {
- /// Only mods can change the post's stickied/locked status. So if either of these is changed from
- /// the current value, it is a mod action and needs to be verified as such.
+ /// Only mods can change the post's locked status. So if it is changed from the default value,
+ /// it is a mod action and needs to be verified as such.
///
- /// Both stickied and locked need to be false on a newly created post (verified in [[CreatePost]].
+ /// Locked needs to be false on a newly created post (verified in [[CreatePost]].
pub(crate) async fn is_mod_action(
&self,
context: &Data<LemmyContext>,
) -> Result<bool, LemmyError> {
let old_post = self.id.clone().dereference_local(context).await;
-
- let featured_changed = Page::is_featured_changed(&old_post, &self.stickied);
- let locked_changed = Page::is_locked_changed(&old_post, &self.comments_enabled);
- Ok(featured_changed || locked_changed)
- }
-
- pub(crate) fn is_featured_changed<E>(
- old_post: &Result<ApubPost, E>,
- new_featured_community: &Option<bool>,
- ) -> bool {
- if let Some(new_featured_community) = new_featured_community {
- if let Ok(old_post) = old_post {
- return new_featured_community != &old_post.featured_community;
- }
- }
-
- false
+ Ok(Page::is_locked_changed(&old_post, &self.comments_enabled))
}
pub(crate) fn is_locked_changed<E>(
slur_filter_regex -> Nullable<Text>,
actor_name_max_length -> Int4,
federation_enabled -> Bool,
- federation_debug -> Bool,
federation_worker_count -> Int4,
captcha_enabled -> Bool,
#[max_length = 255]
pub actor_name_max_length: i32,
/// Whether federation is enabled.
pub federation_enabled: bool,
- pub federation_debug: bool,
/// The number of concurrent federation http workers.
pub federation_worker_count: i32,
/// Whether captcha is enabled.
pub slur_filter_regex: Option<String>,
pub actor_name_max_length: Option<i32>,
pub federation_enabled: Option<bool>,
- pub federation_debug: Option<bool>,
pub federation_worker_count: Option<i32>,
pub captcha_enabled: Option<bool>,
pub captcha_difficulty: Option<String>,
pub slur_filter_regex: Option<Option<String>>,
pub actor_name_max_length: Option<i32>,
pub federation_enabled: Option<bool>,
- pub federation_debug: Option<bool>,
pub federation_worker_count: Option<i32>,
pub captcha_enabled: Option<bool>,
pub captcha_difficulty: Option<String>,
--- /dev/null
+alter table local_site add column federation_debug int default 0;
\ No newline at end of file
--- /dev/null
+alter table local_site drop column federation_debug;
\ No newline at end of file