pub struct CommentsConfig {
pub max_depth: i64,
pub max_length: usize,
pub reactions: Vec<String>,
pub auto_approve: AutoApprove,
pub edit_window: i64,
pub rate_limit: u32,
pub revisions: bool,
pub broadcast: BroadcastChannel,
}Expand description
The package’s settings, read from the environment. An application changes them in
with_config:
use laravel_comments::CommentsConfig;
Application::configure().with_config(|config, _| {
config.section_mut::<CommentsConfig>().reactions = vec!["like".into(), "heart".into()];
})Fields§
§max_depth: i64The deepest level a reply may sit at: 0 for top-level comments, 1 for their replies,
and so on. A reply to a comment at this level joins its parent’s replies instead, as on
Reddit. 0 turns replies off.
max_length: usizeThe most characters a comment’s text may have.
reactions: Vec<String>The reactions people may leave on a comment, such as like or heart.
auto_approve: AutoApproveWhich new comments are approved at once, unless the application sets a rule of its own
with CommentsServiceProvider::moderate_with.
edit_window: i64For how many minutes after posting an author may edit a comment, by the default policy.
0 for no limit.
rate_limit: u32How many comments an author may post a minute, by throttle: users
by their key, guests by their IP address. 0 for no limit.
revisions: boolWhether to keep the text before each edit, for CommentModel::revisions.
broadcast: BroadcastChannelWhether and how the events broadcast, on the channel comments.{type}.{id} of the model
the comment belongs to.
Implementations§
Source§impl CommentsConfig
impl CommentsConfig
Sourcepub fn from_env(env: &Env) -> Self
pub fn from_env(env: &Env) -> Self
Read the section from the environment, starting from its defaults.
| Field | Variable | Default |
|---|---|---|
max_depth | COMMENTS_MAX_DEPTH | 8 |
max_length | COMMENTS_MAX_LENGTH | 10_000 |
reactions | COMMENTS_REACTIONS, comma-separated | vec!["like".to_owned()] |
auto_approve | COMMENTS_AUTO_APPROVE | AutoApprove::Users |
edit_window | COMMENTS_EDIT_WINDOW | 0 |
rate_limit | COMMENTS_RATE_LIMIT | 10 |
revisions | COMMENTS_REVISIONS | true |
broadcast | COMMENTS_BROADCAST | BroadcastChannel::Off |
from_env records invalid values and missing required values in env. Those problems
stop the application from starting.
Trait Implementations§
Source§impl Clone for CommentsConfig
impl Clone for CommentsConfig
Source§impl Debug for CommentsConfig
impl Debug for CommentsConfig
Auto Trait Implementations§
impl Forget for CommentsConfig
impl Freeze for CommentsConfig
impl Move for CommentsConfig
impl RefUnwindSafe for CommentsConfig
impl Send for CommentsConfigwhere
RawVecInner: Send,
impl Sync for CommentsConfigwhere
RawVecInner: Sync,
impl Unpin for CommentsConfig
impl UnsafeUnpin for CommentsConfig
impl UnwindSafe for CommentsConfigwhere
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more