Plugin Directory


Ignore:
Timestamp:
11/14/2026 10:49:34 PM (less than one hour ago)
Author:
erfanteymouri
Message:

Aiwend 0.10.0 (Aiwend – AI Chatbot): English-only public beta, updated listing and seven screenshots, revised banners and Stable Tag 0.10.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • aiwend/trunk/src/Rest/AdminController.php

    r3789777 r3802562  
    1919final class AdminController
    2020{
     21    private Plugin $plugin;
    2122    private const NS = 'aiwend/v1';
    2223
    23     public function __construct(private Plugin $plugin)
    24     {
     24    public function __construct(Plugin $plugin)
     25    {
     26        $this->plugin = $plugin;
    2527    }
    2628
    … …  
    6264    }
    6365
    64     public function setModule(\WP_REST_Request $r): \WP_REST_Response|\WP_Error
     66    /**
     67     * @return \WP_REST_Response|\WP_Error
     68     */
     69    public function setModule(\WP_REST_Request $r)
    6570    {
    6671        $id = (string) $r['id'];
    … …  
    7479    }
    7580
    76     public function listConnections(): \WP_REST_Response|\WP_Error
     81    /**
     82     * @return \WP_REST_Response|\WP_Error
     83     */
     84    public function listConnections()
    7785    {
    7886        $repo = $this->plugin->connections();
    … …  
    8391    }
    8492
    85     /** Write-only secret: the response contains only the fingerprint, never the credential. */
    86     public function createConnection(\WP_REST_Request $r): \WP_REST_Response|\WP_Error
     93    /** Write-only secret: the response contains only the fingerprint, never the credential.
     94     * @return \WP_REST_Response|\WP_Error */
     95    public function createConnection(\WP_REST_Request $r)
    8796    {
    8897        $repo = $this->plugin->connections();
    … …  
    91100        }
    92101        try {
    93             $id = $repo->create(get_current_blog_id(), (string) $r['provider'], sanitize_text_field((string) $r['label']), (string) $r['secret']);
     102            $id = $repo->create(get_current_blog_id(), (string) $r['provider'], sanitize_text_field((string) $r['label']), new \Aiwend\Secrets\SecretString((string) $r['secret']));
    94103        } catch (\InvalidArgumentException $e) {
    95104            return new \WP_Error('aiwend_invalid', $e->getMessage(), ['status' => 400]);
    … …  
    99108    }
    100109
    101     public function deleteConnection(\WP_REST_Request $r): \WP_REST_Response|\WP_Error
     110    /**
     111     * @return \WP_REST_Response|\WP_Error
     112     */
     113    public function deleteConnection(\WP_REST_Request $r)
    102114    {
    103115        $repo = $this->plugin->connections();
    … …  
    117129    {
    118130        $site = get_current_blog_id();
     131        $uncertainRows = $this->plugin->ledger->uncertain($site, 101); // one more than listed, only to report that the window is cut
    119132        return new \WP_REST_Response([
    120133            'site' => $this->plugin->ledger->balance($site, 'site'),
    … …  
    124137            // Counts only (no addresses): site, client, shared, unknown.
    125138            'exhaustion' => $this->plugin->alerts->current(),
    126             'uncertain' => array_map(static fn($r) => ['request_id' => $r->requestId, 'held_units' => $r->reservedUnits, 'note' => $r->note], $this->plugin->ledger->uncertain($site)),
     139            'uncertain' => array_map(static fn($r) => ['request_id' => $r->requestId, 'held_units' => $r->reservedUnits, 'note' => $r->note], array_slice($uncertainRows, 0, 100)),
     140            // Additive: true when more than the 100 oldest unresolved holds exist (the list is a bounded window, oldest first).
     141            'uncertain_truncated' => count($uncertainRows) > 100,
    127142            // Estimates and held amounts are kept apart from usage the provider reported or an administrator entered.
    128143            'by_basis' => $this->plugin->ledger->usageSummary($site),
    … …  
    131146    }
    132147
    133     public function setBudget(\WP_REST_Request $r): \WP_REST_Response|\WP_Error
     148    /**
     149     * @return \WP_REST_Response|\WP_Error
     150     */
     151    public function setBudget(\WP_REST_Request $r)
    134152    {
    135153        $site = get_current_blog_id();
    … …  
    187205            'callback' => $callback,
    188206            'args' => $args,
    189             'permission_callback' => function () use ($operation): bool|\WP_Error {
     207            'permission_callback' => function () use ($operation) {
    190208                $decision = $this->plugin->policy->check($this->plugin->currentPrincipal(), $operation);
    191209                return $decision->allowed ? true : Errors::response($decision->code, $decision->httpStatus());
Note: See TracChangeset for help on using the changeset viewer.