Skip to content

feat: save group tag in DB on create#70

Merged
lorenzocorallo merged 4 commits intomainfrom
group-search-by-tag
Mar 18, 2026
Merged

feat: save group tag in DB on create#70
lorenzocorallo merged 4 commits intomainfrom
group-search-by-tag

Conversation

@lorenzocorallo
Copy link
Member

No description provided.

@lorenzocorallo lorenzocorallo requested a review from toto04 March 18, 2026 17:00
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Adds an updategroup management command and centralizes group lifecycle operations in GroupManagement (create, update, delete, checkAdderPermission). Middleware now delegates to GroupManagement. Logging expanded to report UPDATE and UPDATE_FAIL; dependency @polinetwork/backend bumped.

Changes

Cohort / File(s) Summary
Dependency
package.json
Bumped @polinetwork/backend from ^0.15.3 to ^0.15.5.
Management command
src/commands/management/groups.ts, src/commands/management/index.ts
Added private updategroup command (owner/direttivo) that fetches chat and calls GroupManagement.update; integrated groups into management collection.
Group management core
src/lib/group-management/index.ts
Refactored API surface: create(chatId: number, addedBy: User), added update(chatId: number, requestedBy: User) and checkAdderPermission(chat, addedBy); improved error handling, logging, and backend mutation flows.
Middleware adaption
src/middlewares/bot-membership-handler.ts
Replaced instance methods with static isJoin; removed internal create/update/delete/checkAdderPermission logic and delegated to GroupManagement calls.
Logger changes
src/modules/tg-logger/index.ts, src/modules/tg-logger/types.ts
Extended GroupManagement logging to handle UPDATE / UPDATE_FAIL (in addition to CREATE/CREATE_FAIL); conditional labels and reply_markup (invite link) on failures.
Exports / signatures
src/commands/management/index.ts, src/lib/group-management/index.ts, src/middlewares/...
Public exports/signatures updated: exported groups command; management collection now includes groups; GroupManagement methods signatures changed/added; middleware method signatures adjusted.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Command as "updategroup\nHandler"
    participant API as "Telegram API"
    participant GroupMgmt as "GroupManagement"
    participant Backend as "Backend API"
    participant Logger as "TG Logger"

    User->>Command: /updategroup <chatId>
    Command->>API: getChat(chatId)
    API-->>Command: chat details
    Command->>GroupMgmt: update(chatId, requestedBy)
    GroupMgmt->>API: getChat(chatId)
    API-->>GroupMgmt: chat details
    alt chat exists & has invite_link
        GroupMgmt->>Backend: updateGroup mutation
        Backend-->>GroupMgmt: success
        GroupMgmt->>Logger: emit UPDATE event
        Logger-->>Command: confirmation
        Command-->>User: success reply
    else error / validation fail
        GroupMgmt->>Logger: emit UPDATE_FAIL event
        Logger-->>Command: error message (may include invite link)
        Command-->>User: error reply
    end
Loading

Possibly related PRs

  • feat: grant user special permissions #62: Modifies the same tg-logger module (types.ts and index.ts) to add grant-related logging—both PRs extend the logging infrastructure to handle additional event types.
🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: save group tag in DB on create' accurately describes the primary change: persisting group tags during group creation, which is evidenced by the GroupManagement.create signature update and tag being added to newGroup.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Copy link
Contributor

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/management/groups.ts`:
- Line 12: Update the user-facing text: change the command's description string
(the description property in this command definition currently set to "Get the
audit log of a user") to an accurate description of this command's purpose, and
fix the grammar in the error message that currently reads "does not exists" to
"does not exist" (search for that exact phrase in this file and update the
corresponding user-facing reply/throw). Ensure both the description property and
the user-facing error string are corrected to the intended, grammatical copy.

In `@src/lib/group-management/index.ts`:
- Around line 68-70: The code calls errorBackend(chat, "CREATE", res[0] !==
chat.id) which treats an empty res array as a mismatch; change the logic to
detect emptiness first and only mark a fatal mismatch when res.length > 0 and
res[0] !== chat.id (e.g., compute mismatch = res.length > 0 && res[0] !==
chat.id) and pass that to errorBackend; apply the same fix to the other
occurrence around lines 99-101 so empty responses are not classified as fatal.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2ad76c49-7290-4e29-aba3-ac8e0a792a00

📥 Commits

Reviewing files that changed from the base of the PR and between bf2bea0 and d0a1b7c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • package.json
  • src/commands/management/groups.ts
  • src/commands/management/index.ts
  • src/lib/group-management/index.ts
  • src/middlewares/bot-membership-handler.ts
  • src/modules/tg-logger/index.ts
  • src/modules/tg-logger/types.ts

@lorenzocorallo lorenzocorallo merged commit 439adf3 into main Mar 18, 2026
1 of 2 checks passed
@lorenzocorallo lorenzocorallo deleted the group-search-by-tag branch March 18, 2026 18:57
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.

2 participants