Plugin Directory


Ignore:
Timestamp:
10/28/2026 09:22:17 PM (7 days ago)
Author:
meumouse
Message:

Release 2.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • joinotify/trunk/admin/src/Api/Webhook_Handler.php

    r3678949 r3771693  
    101101     * Record what actually happened to a message that was accepted earlier.
    102102     *
    103      * @since 2.3.0
     103     * Each transition also leaves its time in the row's `delivery` details, so
     104     * a message that was read still shows when it was delivered. A refusal for
     105     * a closed 24-hour window marks the row as sent outside it, whatever the
     106     * send path knew at the time.
     107     *
     108     * @since 2.3.0
     109     * @version 2.6.0
    104110     * @param array $status | Single status entry.
    105111     * @return void
    … …  
    114120
    115121        $error = '';
     122        $timestamp = (int) ( $status['timestamp'] ?? 0 );
     123
     124        $meta = array(
     125            'delivery' => array(
     126                $state . '_at' => gmdate( 'Y-m-d H:i:s', $timestamp > 0 ? $timestamp : time() ),
     127            ),
     128        );
    116129
    117130        if ( 'failed' === $state ) {
    118131            $first = isset( $status['errors'][0] ) && is_array( $status['errors'][0] ) ? $status['errors'][0] : array();
    119132            $error = (string) ( $first['title'] ?? $first['message'] ?? 'delivery_failed' );
     133
     134            if ( Send_Error::WINDOW_CLOSED_META_CODE === (int) ( $first['code'] ?? 0 ) ) {
     135                $meta['session_window'] = 'closed';
     136            }
    120137
    121138            Debug_Log::record( array(
    … …  
    134151        // transitions are worth writing back.
    135152        if ( in_array( $state, array( 'delivered', 'read', 'failed' ), true ) ) {
    136             Message_History::update_status_by_wamid( $wamid, $state, $error );
     153            Message_History::update_status_by_wamid( $wamid, $state, $error, $meta );
    137154        }
    138155    }
    … …  
    168185     *
    169186     * @since 2.3.0
     187     * @version 2.6.0
    170188     * @param string $phone | Contact phone number.
    171189     * @return void
    … …  
    179197
    180198        set_transient( self::WINDOW_PREFIX . md5( $phone ), time(), DAY_IN_SECONDS );
     199
     200        // The platform has just seen the message too; the next read asks it again.
     201        Contact_Window::forget( $phone );
    181202    }
    182203
Note: See TracChangeset for help on using the changeset viewer.