Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions limits.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) 2026 Tulir Asokan
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package whatsmeow

import (
"context"
"encoding/json"
"fmt"

"go.mau.fi/whatsmeow/types"
)

const (
queryNewChatMessageCappingInfo = "24503548349331633"
queryAccountReachoutTimelock = "23983697327930364"
)

type respGetNewChatMessageCappingInfo struct {
MessageCappingInfo *types.NewChatMessageCappingInfo `json:"xwa2_message_capping_info"`
}

type respGetAccountReachoutTimelock struct {
ReachoutTimelock *types.AccountReachoutTimelock `json:"xwa2_fetch_account_reachout_timelock"`
}

// GetNewChatMessageCappingInfo fetches raw MEX capping info for caller-invoked
func (cli *Client) GetNewChatMessageCappingInfo(ctx context.Context) (*types.NewChatMessageCappingInfo, error) {
data, err := cli.sendMexIQ(ctx, queryNewChatMessageCappingInfo, map[string]any{
"input": map[string]any{
"type": "INDIVIDUAL_NEW_CHAT_MSG",
},
})
var respData respGetNewChatMessageCappingInfo
if data != nil {
jsonErr := json.Unmarshal(data, &respData)
if err == nil && jsonErr != nil {
err = jsonErr
} else if err == nil && respData.MessageCappingInfo == nil {
err = fmt.Errorf("mex unexpected null response for new chat message capping info")
}
}
return respData.MessageCappingInfo, err
}

// GetAccountReachoutTimelock fetches raw MEX reachout timelock info
func (cli *Client) GetAccountReachoutTimelock(ctx context.Context) (*types.AccountReachoutTimelock, error) {
data, err := cli.sendMexIQ(ctx, queryAccountReachoutTimelock, map[string]any{})
var respData respGetAccountReachoutTimelock
if data != nil {
jsonErr := json.Unmarshal(data, &respData)
if err == nil && jsonErr != nil {
err = jsonErr
} else if err == nil && respData.ReachoutTimelock == nil {
err = fmt.Errorf("mex unexpected null response for fetching reachout timelock")
}
}
return respData.ReachoutTimelock, err
}
24 changes: 24 additions & 0 deletions types/limits.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2026 Tulir Asokan
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

package types

type NewChatMessageCappingInfo struct {
TotalQuota int `json:"total_quota"`
UsedQuota int `json:"used_quota"`
CycleStartTimestamp string `json:"cycle_start_timestamp"`
CycleEndTimestamp string `json:"cycle_end_timestamp"`
ServerSentTimestamp string `json:"server_sent_timestamp"`
Comment thread
gusquadri marked this conversation as resolved.
Outdated
OTEStatus string `json:"ote_status"`
MVStatus string `json:"mv_status"`
CappingStatus string `json:"capping_status"`
Comment thread
gusquadri marked this conversation as resolved.
Outdated
}

type AccountReachoutTimelock struct {
IsActive bool `json:"is_active"`
TimeEnforcementEnds string `json:"time_enforcement_ends"`
Comment thread
gusquadri marked this conversation as resolved.
Outdated
EnforcementType string `json:"enforcement_type"`
Comment thread
gusquadri marked this conversation as resolved.
Outdated
}
Loading