pub struct CommentsServiceProvider { /* private fields */ }Expand description
Adds the package’s settings, its migrations, and the application’s moderation and mention rules.
Implementations§
Source§impl CommentsServiceProvider
impl CommentsServiceProvider
Sourcepub fn moderate_with<F, Fut>(self, rule: F) -> Self
pub fn moderate_with<F, Fut>(self, rule: F) -> Self
Gives each new comment the status rule returns, instead of COMMENTS_AUTO_APPROVE: a
place for trusted authors, banned words, or a spam check.
use laravel_comments::{CommentsServiceProvider, NewComment, Status};
let provider = CommentsServiceProvider::new().moderate_with(async |comment: NewComment| {
if comment.body.contains("casino") {
return Ok(Status::Spam);
}
Ok(if comment.author_id.is_some() { Status::Approved } else { Status::Pending })
});Sourcepub fn mentions_with<F, Fut>(self, rule: F) -> Self
pub fn mentions_with<F, Fut>(self, rule: F) -> Self
Turns @name mentions on: rule gets the names a comment mentions, lowercased, and
returns the keys of the users they name. Each mentioned user gets one
UserMentioned once the comment is visible.
use laravel_comments::CommentsServiceProvider;
let provider = CommentsServiceProvider::new().mentions_with(async |names: Vec<String>| {
User::query().filter(User::username.is_in(names)).pluck(User::id).await
});Trait Implementations§
Source§impl Clone for CommentsServiceProvider
impl Clone for CommentsServiceProvider
Source§impl Default for CommentsServiceProvider
impl Default for CommentsServiceProvider
Auto Trait Implementations§
impl !RefUnwindSafe for CommentsServiceProvider
impl !UnwindSafe for CommentsServiceProvider
impl Forget for CommentsServiceProvider
impl Freeze for CommentsServiceProviderwhere
*const ArcInner<dyn Fn(NewComment) -> Pin<Box<dyn Future<Output = Result<Status, Error>> + Send>> + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(NewComment) -> Pin<Box<dyn Future<Output = Result<Status, Error>> + Send>> + Sync + Send>>: Freeze,
*const ArcInner<dyn Fn(Vec<String>) -> Pin<Box<dyn Future<Output = Result<Vec<i64>, Error>> + Send>> + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(Vec<String>) -> Pin<Box<dyn Future<Output = Result<Vec<i64>, Error>> + Send>> + Sync + Send>>: Freeze,
impl Move for CommentsServiceProvider
impl Send for CommentsServiceProvider
impl Sync for CommentsServiceProvider
impl Unpin for CommentsServiceProvider
impl UnsafeUnpin for CommentsServiceProviderwhere
*const ArcInner<dyn Fn(NewComment) -> Pin<Box<dyn Future<Output = Result<Status, Error>> + Send>> + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(NewComment) -> Pin<Box<dyn Future<Output = Result<Status, Error>> + Send>> + Sync + Send>>: UnsafeUnpin,
*const ArcInner<dyn Fn(Vec<String>) -> Pin<Box<dyn Future<Output = Result<Vec<i64>, Error>> + Send>> + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(Vec<String>) -> Pin<Box<dyn Future<Output = Result<Vec<i64>, Error>> + Send>> + Sync + Send>>: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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