Skip to content

fix: ereputation erefernce#943

Merged
coodos merged 4 commits intomainfrom
fix/ereputation-api-issue
Apr 3, 2026
Merged

fix: ereputation erefernce#943
coodos merged 4 commits intomainfrom
fix/ereputation-api-issue

Conversation

@coodos
Copy link
Copy Markdown
Contributor

@coodos coodos commented Apr 3, 2026

Description of change

fix bug with ereference from cerberus not saving

Issue Number

Type of change

  • Fix (a change which fixes an issue)

How the change has been tested

Change checklist

  • I have ensured that the CI Checks pass locally
  • I have removed any unnecessary logic
  • My code is well documented
  • I have signed my commits
  • My code follows the pattern of the application
  • I have self reviewed my code

Summary by CodeRabbit

  • New Features

    • Reference creation now supports resolving targets by entity name, with automatic fallback to ID-based resolution for users.
    • System-generated references are now automatically attributed to a system account instead of requiring explicit author specification.
  • Chores

    • Updated build process to include mapping files in distribution output.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef7f24b1-fc2f-4161-b4f0-3fc50e720a10

📥 Commits

Reviewing files that changed from the base of the PR and between 2416ed1 and 2ecc1c2.

📒 Files selected for processing (3)
  • platforms/cerberus/client/src/services/ReferenceWriterService.ts
  • platforms/ereputation/api/package.json
  • platforms/ereputation/api/src/controllers/ReferenceController.ts

📝 Walkthrough

Walkthrough

The changes extend the eReputation API integration by adding targetEname field to request payloads, modify the build script to copy mapping files, and refactor system reference creation to use targetEname for user lookup and automatic system user provisioning instead of accepting authorId.

Changes

Cohort / File(s) Summary
eReputation Payload Enhancement
platforms/cerberus/client/src/services/ReferenceWriterService.ts
Added targetEname field to eReputation API request payload.
Build Configuration
platforms/ereputation/api/package.json
Updated build script to copy src/web3adapter/mappings directory into dist/web3adapter/ output.
System Reference Endpoint Refactor
platforms/ereputation/api/src/controllers/ReferenceController.ts
Replaced authorId parameter with targetEname in system reference creation; introduced SYSTEM_AUTHOR_NAME constant and added automatic lookup/creation of "Cerberus Platform" system user; added optional targetEname-to-targetId resolution for user references with fallback logic.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ReferenceController
    participant UserService as AppDataSource/User
    participant Database

    Client->>ReferenceController: createSystemReference(targetEname, targetType, targetId, ...)
    ReferenceController->>UserService: Find or Create "Cerberus Platform" user
    UserService->>Database: Query user by ename "Cerberus Platform"
    alt User exists
        Database-->>UserService: Return user record
    else User not found
        UserService->>Database: Create new system user
        Database-->>UserService: Return created user
    end
    UserService-->>ReferenceController: Return systemUser with authorId

    alt targetType is "user"
        ReferenceController->>UserService: Resolve targetEname to targetId
        alt Resolution succeeds
            UserService-->>ReferenceController: Return resolved targetId
        else Resolution fails
            ReferenceController->>ReferenceController: Use provided targetId as fallback
        end
    end

    ReferenceController->>Database: Create reference with systemUser.authorId, resolved targetId
    Database-->>ReferenceController: Return created reference
    ReferenceController-->>Client: Return reference response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Feat/cerberus erep #940: Directly related integration of ReferenceWriterService client-side payload extensions and ReferenceController system reference endpoint modifications—both PRs modify the same reference integration codepaths.

Suggested reviewers

  • sosweetham
  • xPathin

Poem

🐰 A whisker-twitching tale of targetEname delight,
Where Cerberus Platform users materialize just right,
System references now resolve with automated grace,
No more hardcoded authorId slowing down the race! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ereputation-api-issue

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.

@coodos coodos marked this pull request as ready for review April 3, 2026 10:31
@coodos coodos merged commit 68e29d1 into main Apr 3, 2026
4 checks passed
@coodos coodos deleted the fix/ereputation-api-issue branch April 3, 2026 10:31
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