Skip to content

INTGRTNS-502: Replace local DB mailbox limit with live statistics API - #5

Open
msiouti wants to merge 1 commit into
openprovider:masterfrom
msiouti:INTGRTNS-502-live-mailbox-limit
Open

INTGRTNS-502: Replace local DB mailbox limit with live statistics API#5
msiouti wants to merge 1 commit into
openprovider:masterfrom
msiouti:INTGRTNS-502-live-mailbox-limit

Conversation

@msiouti

@msiouti msiouti commented Apr 29, 2026

Copy link
Copy Markdown

What

Replaces the stale local DB mailbox limit with live data from GET /v1beta/mailcow/statistics.

Changes

  • addMailbox handler uses total_count/used_count from statistics API instead of stale local DB
  • countMailBox template var uses live contracted count
  • Graceful fallback to local DB if API call fails
  • Removes orphaned print_r($_POST); die() debug line from editMailbox handler

Why

mod_email_solution_product.mailcow drifts when orders are modified outside WHMCS. GET /v1beta/mailcow/statistics already exists and returns the correct live contracted count.

Refs

Closes INTGRTNS-502 | Original: INTGRTNS-501 | Storage follow-up: INTGRTNS-503

… print_r line

Replace stale local DB mailbox limit with live data from /v1beta/mailcow/statistics.

- Use total_count (contracted licenses) and used_count from statistics API
- Add graceful fallback to local DB if API call fails
- Fix countMailBox template var to use live contracted count
- Remove orphaned debug print_r/die() line in editMailbox handler

Ref: INTGRTNS-502
@YumeChaan
YumeChaan self-requested a review May 11, 2026 06:58

@YumeChaan YumeChaan 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.

Please remove the unnecessary whitespace/empty lines in this file as well. It makes the actual changes a bit difficult to see.


// [INTGRTNS-502]

'countMailBox' => isset($statistics) && $statistics['httpcode'] == 200 ? (int)$statistics['result']->data->total_count : Capsule::table('mod_email_solution_product')->where('service_id', $params['serviceid'])->value('mailcow'),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

$statistics is only defined inside the addMailbox POST block. Because of that, during normal ClientArea page loads this condition falls back to the local DB value instead of using the live statistics API value.




function email_solution_AdminServicesTabFields(array $params)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

AdminServicesTabFields is still using /v1beta/mailcow/orders and displaying data->total as "Total No Of Mailbox". According to the ticket, this should use /v1beta/mailcow/statistics and display total_count and used_count instead.

{

try {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SuspendAccount and UnsuspendAccount are still empty stubs. The ticket asks to add a note or basic implementation, so this part is still pending.

{

try {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SuspendAccount and UnsuspendAccount are still empty stubs. The ticket asks to add a note or basic implementation, so this part is still pending.

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