Skip to content

Announcement Setting Implementation - #51

Merged
OmarLawaty merged 5 commits into
devfrom
feat/settings/announcement
Aug 19, 2026
Merged

OmarLawaty merged 5 commits into
devfrom
feat/settings/announcement

Conversation

@OmarLawaty

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a new “announcement” setting, including DTOs for admin/user responses, persistence via the existing settings table, and media attachments via a new setting_media join table integrated into the media lifecycle.

Changes:

  • Added announcement setting DTOs (admin + user) and wired it into SETTINGS_MAP / settings endpoints serialization.
  • Introduced SettingMedia join entity + migration, and updated settings reads/writes to include ordered media attachments.
  • Extended media domain to support announcement uploads/policies and prevent referenced media cleanup.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/settings/settings.service.ts Loads/saves settings with related media attachments; adds transactional attach/detach logic.
src/settings/settings.module.ts Registers SettingMedia repository and imports MediaModule.
src/settings/entities/setting.entity.ts Adds OneToMany relation from Setting → SettingMedia.
src/settings/dtos/user/settings.dto.ts Exposes announcement in the public settings response.
src/settings/dtos/user/maintenance-mode.dto.ts Adjusts user-facing maintenance fields to hide message/countdown when disabled.
src/settings/dtos/user/announcement.dto.ts Adds user-facing announcement DTO (localized message + media, hides admin-only fields).
src/settings/dtos/announcement.setting.dto.ts Adds the persisted/validated announcement setting schema + cron handler.
src/settings/dtos/admin/admin-settings.dto.ts Exposes announcement in the admin settings response.
src/settings/const.ts Registers announcement in SETTINGS_MAP.
src/media/services/media.service.ts Treats setting_media as a reference to prevent draft cleanup.
src/media/entities/setting-media.entity.ts New join entity mapping ordered media attachments to a setting.
src/media/const.ts Adds announcement to supported media entity types.
src/media/cloudinary/const.ts Adds Cloudinary policy for announcement uploads.
src/i18n/messages/en.ts Adds translation for settings.settingNotFound.
src/i18n/messages/ar.ts Adds Arabic translation for settings.settingNotFound.
migrations/1786904184459-AnnouncementSettingMedia.ts Creates the setting_media table and FKs.
Suppressed comments (1)

src/settings/settings.service.ts:97

  • attachMediaToSetting() is detaching drafts using setting.media[i].id, but id here is the SettingMedia row id, not the referenced Media id. Also, the current query only loads the SettingMedia rows (relations: { media: true }) without loading the nested SettingMedia.media relation, so there isn’t enough data to detach the actual media records. Load the nested relation and detach using sm.media.id.
    const setting = await repo.findOne({
      where: { key },
      select: { id: true, media: { id: true } },
      relations: { media: true },
    });

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/settings/settings.service.ts
@OmarLawaty
OmarLawaty merged commit a830002 into dev Aug 19, 2026
2 checks passed
@OmarLawaty
OmarLawaty deleted the feat/settings/announcement branch August 19, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants