pub struct NoticeUseCases { /* private fields */ }Implementations§
Source§impl NoticeUseCases
impl NoticeUseCases
pub fn new( notice_repo: Arc<dyn NoticeRepository>, owner_repo: Arc<dyn OwnerRepository>, ) -> Self
Sourcepub async fn create_notice(
&self,
author_id: Uuid,
dto: CreateNoticeDto,
) -> Result<NoticeResponseDto, String>
pub async fn create_notice( &self, author_id: Uuid, dto: CreateNoticeDto, ) -> Result<NoticeResponseDto, String>
Create a new notice (Draft status)
§Authorization
- Author must be a member of the building (validated by owner_repo)
Sourcepub async fn get_notice(
&self,
notice_id: Uuid,
) -> Result<NoticeResponseDto, String>
pub async fn get_notice( &self, notice_id: Uuid, ) -> Result<NoticeResponseDto, String>
Get notice by ID with author name enrichment
Sourcepub async fn list_building_notices(
&self,
building_id: Uuid,
) -> Result<Vec<NoticeSummaryDto>, String>
pub async fn list_building_notices( &self, building_id: Uuid, ) -> Result<Vec<NoticeSummaryDto>, String>
List all notices for a building (all statuses)
§Returns
- Notices sorted by pinned (DESC), created_at (DESC)
Sourcepub async fn list_published_notices(
&self,
building_id: Uuid,
) -> Result<Vec<NoticeSummaryDto>, String>
pub async fn list_published_notices( &self, building_id: Uuid, ) -> Result<Vec<NoticeSummaryDto>, String>
List published notices for a building (visible to members)
§Returns
- Only Published notices, sorted by pinned (DESC), published_at (DESC)
Sourcepub async fn list_pinned_notices(
&self,
building_id: Uuid,
) -> Result<Vec<NoticeSummaryDto>, String>
pub async fn list_pinned_notices( &self, building_id: Uuid, ) -> Result<Vec<NoticeSummaryDto>, String>
List pinned notices for a building (important announcements)
Sourcepub async fn list_notices_by_type(
&self,
building_id: Uuid,
notice_type: NoticeType,
) -> Result<Vec<NoticeSummaryDto>, String>
pub async fn list_notices_by_type( &self, building_id: Uuid, notice_type: NoticeType, ) -> Result<Vec<NoticeSummaryDto>, String>
List notices by type (Announcement, Event, LostAndFound, ClassifiedAd)
Sourcepub async fn list_notices_by_category(
&self,
building_id: Uuid,
category: NoticeCategory,
) -> Result<Vec<NoticeSummaryDto>, String>
pub async fn list_notices_by_category( &self, building_id: Uuid, category: NoticeCategory, ) -> Result<Vec<NoticeSummaryDto>, String>
List notices by category (General, Maintenance, Social, etc.)
Sourcepub async fn list_notices_by_status(
&self,
building_id: Uuid,
status: NoticeStatus,
) -> Result<Vec<NoticeSummaryDto>, String>
pub async fn list_notices_by_status( &self, building_id: Uuid, status: NoticeStatus, ) -> Result<Vec<NoticeSummaryDto>, String>
List notices by status (Draft, Published, Archived, Expired)
List all notices created by an author
Sourcepub async fn update_notice(
&self,
notice_id: Uuid,
actor_id: Uuid,
dto: UpdateNoticeDto,
) -> Result<NoticeResponseDto, String>
pub async fn update_notice( &self, notice_id: Uuid, actor_id: Uuid, dto: UpdateNoticeDto, ) -> Result<NoticeResponseDto, String>
Update a notice (Draft only)
§Authorization
- Only author can update their notice
- Only Draft notices can be updated
Sourcepub async fn publish_notice(
&self,
notice_id: Uuid,
actor_id: Uuid,
) -> Result<NoticeResponseDto, String>
pub async fn publish_notice( &self, notice_id: Uuid, actor_id: Uuid, ) -> Result<NoticeResponseDto, String>
Sourcepub async fn archive_notice(
&self,
notice_id: Uuid,
actor_id: Uuid,
actor_role: &str,
) -> Result<NoticeResponseDto, String>
pub async fn archive_notice( &self, notice_id: Uuid, actor_id: Uuid, actor_role: &str, ) -> Result<NoticeResponseDto, String>
Archive a notice (Published/Expired → Archived)
§Authorization
- Only author or building admin can archive
Sourcepub async fn pin_notice(
&self,
notice_id: Uuid,
actor_role: &str,
) -> Result<NoticeResponseDto, String>
pub async fn pin_notice( &self, notice_id: Uuid, actor_role: &str, ) -> Result<NoticeResponseDto, String>
Pin a notice to top of board (Published only)
§Authorization
- Only building admin (admin, superadmin, or syndic) can pin notices
Sourcepub async fn unpin_notice(
&self,
notice_id: Uuid,
actor_role: &str,
) -> Result<NoticeResponseDto, String>
pub async fn unpin_notice( &self, notice_id: Uuid, actor_role: &str, ) -> Result<NoticeResponseDto, String>
Sourcepub async fn set_expiration(
&self,
notice_id: Uuid,
actor_id: Uuid,
dto: SetExpirationDto,
) -> Result<NoticeResponseDto, String>
pub async fn set_expiration( &self, notice_id: Uuid, actor_id: Uuid, dto: SetExpirationDto, ) -> Result<NoticeResponseDto, String>
Sourcepub async fn delete_notice(
&self,
notice_id: Uuid,
actor_id: Uuid,
) -> Result<(), String>
pub async fn delete_notice( &self, notice_id: Uuid, actor_id: Uuid, ) -> Result<(), String>
Delete a notice
§Authorization
- Only author can delete their notice
- Cannot delete Published/Archived notices (must archive first)
Sourcepub async fn auto_expire_notices(
&self,
building_id: Uuid,
) -> Result<Vec<Uuid>, String>
pub async fn auto_expire_notices( &self, building_id: Uuid, ) -> Result<Vec<Uuid>, String>
Automatically expire notices that have passed their expiration date
§Background Job
- Should be called periodically (e.g., daily cron job)
- Finds all Published notices with expires_at in the past
- Transitions them to Expired status
Sourcepub async fn get_statistics(
&self,
building_id: Uuid,
) -> Result<NoticeStatistics, String>
pub async fn get_statistics( &self, building_id: Uuid, ) -> Result<NoticeStatistics, String>
Get notice statistics for a building
Auto Trait Implementations§
impl Freeze for NoticeUseCases
impl !RefUnwindSafe for NoticeUseCases
impl Send for NoticeUseCases
impl Sync for NoticeUseCases
impl Unpin for NoticeUseCases
impl !UnwindSafe for NoticeUseCases
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<T> Chain<T> for T
impl<T> Chain<T> for T
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moreCreates a shared type from an unshared type.