Skip to content

chore: queue updated#207

Merged
hmbanan666 merged 2 commits intomainfrom
queue-update
Oct 8, 2025
Merged

chore: queue updated#207
hmbanan666 merged 2 commits intomainfrom
queue-update

Conversation

@hmbanan666
Copy link
Copy Markdown
Collaborator

@hmbanan666 hmbanan666 commented Oct 8, 2025

Summary by CodeRabbit

  • New Features

    • Richer notifications for ticket messages and epic comments, now including sender details and message text.
  • Improvements

    • More reliable, centralized event delivery and handling across services.
    • Clearer, data-driven processing for Telegram notifications.
  • Refactor

    • Unified event publishing model and standardized event names.
    • Simplified consumer dispatch using event-to-handler mapping.
  • Chores

    • Updated dependencies, including queue infrastructure and icon set versions.

@hmbanan666 hmbanan666 self-assigned this Oct 8, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 8, 2025

Walkthrough

Refactors event dispatch to a centralized Events-based publish/consume model: replaces per-entity queue methods with queue.publish(...) and an EventHandlerMap consumer, renames Events enum keys to camelCase, removes entity-specific publish helpers, updates types and handlers signatures, and bumps @nextorders/queue to ^0.2.0.

Changes

Cohort / File(s) Summary
API event publishers
apps/atrium-telegram/server/api/ticket/id/[ticketId]/message.post.ts, apps/web-app/server/api/ticket/id/[ticketId]/message.post.ts, apps/web-app/server/api/beacon/epic/comment.post.ts
Replace nested queue methods with queue.publish<T>(Events.<event>, ...); add/import typed event interfaces and include expanded payload fields (userId, userName, userSurname, userText / notification fields).
Core Telegram consumer dispatch
apps/core-telegram/server/services/queue/index.ts
Replace type-checked switch with queue.consume(queue.telegram.name, { ... } as EventHandlerMap); handler signatures now accept data (typed) and return boolean; internal access changed from msg.data.* to data.*.
Essence public API & types
packages/essence/src/index.ts, packages/essence/src/queue/types.ts
Export Events; rename enum keys to camelCase; redefine EventMessage as explicit union; add EventHandler, EventMessageHandler, EventHandlerMap; expand event data shapes to include new fields.
Essence queue entities
packages/essence/src/queue/entities/ticket.ts, packages/essence/src/queue/entities/notification.ts, packages/essence/src/queue/entities/telegram.ts
Remove entity helper methods Ticket.messageCreated and Notification.userBeaconOnEpicCommentCreated; update telegram entity to use camelCase Events keys for eventsToConsume.
Workspace deps & misc
pnpm-workspace.yaml, apps/webinar/app/app.vue
Bump @nextorders/queue to ^0.2.0 and @iconify-json/lucide to ^1.2.69; add <script src="/vk-pixel.min.js"> via useHead in webinar app.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant API as API (web/atrium)
  participant Q as queue.publish
  participant EX as Events Exchange
  participant TG as Telegram Consumer

  rect rgb(240,248,255)
  note over API: create message / beacon
  API->>Q: publish(Events.ticketMessageCreated, data)
  API->>Q: publish(Events.notificationUserBeaconOnEpicCommentCreated, data)
  Q->>EX: route by event key
  end

  rect rgb(245,255,240)
  EX-->>TG: ticketMessageCreated / notificationUserBeaconOnEpicCommentCreated + data
  TG->>TG: dispatch via EventHandlerMap
  TG->>TG: handler(data) → boolean
  end
Loading
sequenceDiagram
  autonumber
  participant EX as Events Exchange
  participant Q as queue.consume(name, handlers)
  participant H1 as handleTicketMessageCreated
  participant H2 as handleUserBeaconOnEpicCommentCreated

  EX-->>Q: event + data
  alt event == ticketMessageCreated
    Q->>H1: data
    H1-->>Q: true / false
  else event == notificationUserBeaconOnEpicCommentCreated
    Q->>H2: data
    H2-->>Q: true / false
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • feat: tickets dir in atrium #53: Modifies the ticket message POST flow in apps/web-app/server/api/ticket/id/[ticketId]/message.post.ts — closely related to the event publish changes.
  • feat: beacon create action #84: Refactors event types/handlers and moves to a publish-based queue API — overlaps with the Events/type and consumer changes.

Poem

A rabbit taps the event drum, thump-thump—
Old tunnels closed, new routes hum.
CamelCase carrots, types in bloom,
Handlers hop from field to room.
Publish, consume —🥕 off I zoom!

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title “chore: queue updated” is related to the queue changes but is overly generic and does not communicate the core refactoring of event dispatch to a generic publish API with typed Events enum and a new handler mapping; it also fails to highlight the public API signature changes and method removals introduced. As a result, reviewers cannot infer the scope or significance of the changes without examining the full diff. Please update the title to concisely summarize the primary change, for example “refactor queue dispatch to generic publish API with typed Events and handler map,” so that the intent and scope of the refactoring are clear at a glance. A descriptive title will help reviewers quickly understand the nature of the changes without diving into the code.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch queue-update

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@socket-security
Copy link
Copy Markdown

socket-security bot commented Oct 8, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​nextorders/​queue@​0.1.2 ⏵ 0.2.074 -2610099 -190 -10100
Updated@​iconify-json/​lucide@​1.2.68 ⏵ 1.2.69100 +110079 +196 +2100

View full report

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/essence/src/queue/types.ts (1)

13-14: Key handler map on the discriminant property

Indexing by EventMessage['event'] widens the key to string, so each handler is typed to accept the full union of all payloads, which makes it easy to wire the wrong handler/data pair without the compiler catching it. Switching to the literal type discriminant and deriving the payload with Extract restores event-to-payload coupling.

-export type EventHandlerMap = Record(EventMessage['event'], EventMessageHandler)
+export type EventHandlerMap = {
+  [K in EventMessage['type']]: EventMessageHandler<Extract<EventMessage, { type: K }>['data']>
+}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 84d91c5 and d7f3f81.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • apps/atrium-telegram/server/api/ticket/id/[ticketId]/message.post.ts (2 hunks)
  • apps/core-telegram/server/services/queue/index.ts (2 hunks)
  • apps/web-app/server/api/beacon/epic/comment.post.ts (2 hunks)
  • apps/web-app/server/api/ticket/id/[ticketId]/message.post.ts (2 hunks)
  • packages/essence/src/index.ts (1 hunks)
  • packages/essence/src/queue/entities/notification.ts (0 hunks)
  • packages/essence/src/queue/entities/telegram.ts (1 hunks)
  • packages/essence/src/queue/entities/ticket.ts (0 hunks)
  • packages/essence/src/queue/types.ts (2 hunks)
  • pnpm-workspace.yaml (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/essence/src/queue/entities/ticket.ts
  • packages/essence/src/queue/entities/notification.ts
🧰 Additional context used
🧬 Code graph analysis (5)
apps/atrium-telegram/server/api/ticket/id/[ticketId]/message.post.ts (2)
packages/essence/src/queue/types.ts (1)
  • TicketMessageCreated (15-26)
packages/essence/src/index.ts (1)
  • Events (3-3)
apps/core-telegram/server/services/queue/index.ts (3)
packages/essence/src/queue/types.ts (3)
  • EventHandlerMap (13-13)
  • TicketMessageCreated (15-26)
  • NotificationUserBeaconOnEpicCommentCreated (28-39)
apps/core-telegram/server/services/telegram/wasabi-bot.ts (1)
  • useWasabiBot (327-333)
apps/core-telegram/server/services/telegram/atrium-bot.ts (1)
  • useAtriumBot (95-101)
apps/web-app/server/api/ticket/id/[ticketId]/message.post.ts (1)
packages/essence/src/queue/types.ts (1)
  • TicketMessageCreated (15-26)
packages/essence/src/queue/types.ts (1)
packages/essence/src/index.ts (1)
  • Events (3-3)
apps/web-app/server/api/beacon/epic/comment.post.ts (2)
packages/essence/src/queue/types.ts (1)
  • NotificationUserBeaconOnEpicCommentCreated (28-39)
packages/essence/src/index.ts (1)
  • Events (3-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

Comment on lines +21 to 22
const text = `${data.userName} ${data.userSurname}: ${data.userText}`
await useWasabiBot().api.sendMessage(wasabiUser.telegramId, text)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Avoid sending “undefined” in Wasabi notifications

data.userSurname can be undefined, so the current template produces messages like “Alice undefined: …”. This is a regression from the previous defensive formatting and breaks the user experience.

Apply this diff to guard the optional surname:

-      const text = `${data.userName} ${data.userSurname}: ${data.userText}`
+      const surname = data.userSurname ? ` ${data.userSurname}` : ''
+      const text = `${data.userName}${surname}: ${data.userText}`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const text = `${data.userName} ${data.userSurname}: ${data.userText}`
await useWasabiBot().api.sendMessage(wasabiUser.telegramId, text)
const surname = data.userSurname ? ` ${data.userSurname}` : ''
const text = `${data.userName}${surname}: ${data.userText}`
await useWasabiBot().api.sendMessage(wasabiUser.telegramId, text)
🤖 Prompt for AI Agents
In apps/core-telegram/server/services/queue/index.ts around lines 21-22, the
message template interpolates data.userSurname directly which can be undefined
and yields messages like "Alice undefined: ..."; change the interpolation to
safely include the surname only when present (e.g., use a conditional or nullish
coalescing to fall back to an empty string and trim any extra spaces) so that
the final text becomes "Alice: ..." when surname is missing, then send that
sanitized text to useWasabiBot().api.sendMessage.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Oct 8, 2025

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7f3f81 and 4128856.

⛔ Files ignored due to path filters (1)
  • apps/webinar/public/vk-pixel.min.js is excluded by !**/*.min.js
📒 Files selected for processing (1)
  • apps/webinar/app/app.vue (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

Comment on lines +24 to +29
script: [
{
type: 'text/javascript',
src: '/vk-pixel.min.js',
},
],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify this change belongs in the PR and assess privacy/consent requirements.

This script injection appears unrelated to the PR's stated objective (queue event dispatch refactoring). Additionally, adding a tracking pixel raises several concerns:

  1. Scope: This change doesn't align with "queue updated" - consider moving it to a separate PR with proper context.
  2. Privacy/Compliance: VK pixel tracking may require user consent under GDPR/CCPA. Verify that consent management is properly implemented before this script executes.
  3. Security: Confirm this tracking script addition has been reviewed and approved by the appropriate stakeholders.

Optional: Consider async loading for better performance.

The script currently blocks page parsing. If the tracking script is non-critical for initial render, consider adding the async attribute:

 script: [
   {
     type: 'text/javascript',
     src: '/vk-pixel.min.js',
+    async: true,
   },
 ],

🏁 Script executed:

#!/bin/bash
rg -n --color=never "consent" -C3 .
rg -n --color=never "cookie" -C3 .
rg -n --color=never "gdpr" -C3 .
rg -n --color=never "useHead" -C3 apps/webinar/app/app.vue

Length of output: 7611


Separate tracking pixel addition and implement consent gating

  • Remove or move the VK pixel script from this PR; introduce it in a dedicated change with proper context.
  • Gate the tracking script behind explicit user consent (GDPR/CCPA) before injecting.
  • Once consent is granted, load the script asynchronously, for example:
 script: [
   {
     type: 'text/javascript',
     src: '/vk-pixel.min.js',
+    async: true,
   },
 ],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
script: [
{
type: 'text/javascript',
src: '/vk-pixel.min.js',
},
],
script: [
{
type: 'text/javascript',
src: '/vk-pixel.min.js',
async: true,
},
],
🤖 Prompt for AI Agents
In apps/webinar/app/app.vue around lines 24 to 29, the VK tracking pixel script
is being added directly in this PR; remove it from this change and introduce the
pixel in a separate PR with context, and implement consent gating so the script
is only injected after explicit user consent (GDPR/CCPA). Add a consent check
(persisted user choice), and when consent is granted load the pixel
asynchronously by creating and appending a script element at runtime (or using
an async loader) rather than including it in the static script array; ensure the
consent flow and gating logic are covered in the dedicated change.

@hmbanan666 hmbanan666 merged commit 38c9d5e into main Oct 8, 2025
8 checks passed
@hmbanan666 hmbanan666 deleted the queue-update branch October 8, 2025 08:52
@coderabbitai coderabbitai bot mentioned this pull request Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant