Repository navigation
Announcement Setting Implementation - #51
Merged
Merged
Conversation
There was a problem hiding this comment.
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
SettingMediajoin 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 usingsetting.media[i].id, butidhere is theSettingMediarow id, not the referencedMediaid. Also, the current query only loads the SettingMedia rows (relations: { media: true }) without loading the nestedSettingMedia.mediarelation, so there isn’t enough data to detach the actual media records. Load the nested relation and detach usingsm.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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.