Changeset 3787273 for texty/trunk/includes/Dispatcher.php
- Timestamp:
- 11/06/2026 06:15:55 AM (3 days ago)
- File:
-
- 1 edited
-
texty/trunk/includes/Dispatcher.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
texty/trunk/includes/Dispatcher.php
r3640280 r3787273 8 8 use Texty\Dependencies\WeDevs\WPKit\DataLayer\DataLayerFactory; 9 9 use Texty\Gateways\GatewayInterface; 10 use Texty\Gateways\Secrets; 10 11 use WP_Comment; 12 use WP_Error; 11 13 12 14 /** … … 26 28 // SMS Logging via gateway hooks 27 29 add_action( 'texty_after_send_sms', [ $this, 'log_sms' ], 10, 4 ); 30 add_action( 'texty_send_sms_no_gateway', [ $this, 'log_no_gateway' ], 10, 3 ); 28 31 29 32 // Load integrations … … 63 66 */ 64 67 public function user_register( $user_id ) { 65 $class = texty()->notifications()->get( 'registration' ); 66 $notifier = new $class(); 67 68 $notifier->set_user( $user_id ); 69 $notifier->send(); 68 texty()->queue()->push( 'registration', [ 'user_id' => (int) $user_id ] ); 70 69 } 71 70 … … 86 85 } 87 86 88 $class = texty()->notifications()->get( 'comment' ); 89 $notifier = new $class(); 90 91 $notifier->set_comment( $comment_id ); 92 $notifier->send(); 87 texty()->queue()->push( 'comment', [ 'comment_id' => (int) $comment_id ] ); 93 88 } 94 89 … … 141 136 'notification_group' => $notification_group, 142 137 'message' => is_string( $message ) ? $message : '', 143 'response' => $this->encode_response( $result ),138 'response' => $this->encode_response( $result, $gateway ), 144 139 'reference_id' => is_scalar( $reference_id ) ? (string) $reference_id : '', 145 140 'created_at' => current_time( 'mysql' ), … … 152 147 153 148 /** 149 * Log a message that couldn't be sent because no gateway is active. 150 * 151 * Written as a failed row (with the `texty_no_gateway` reason), so the 152 * order note's "details in Texty → Logs" has an entry to point to. 153 * 154 * @since TEXTY_VERSION 155 * 156 * @param WP_Error $error The `texty_no_gateway` error 157 * @param string $to Recipient phone number 158 * @param string $message The message body 159 * 160 * @return void 161 */ 162 public function log_no_gateway( $error, $to, $message ) { 163 $this->log_sms( $error, $to, $message, false ); 164 } 165 166 /** 154 167 * Normalize the gateway result into a JSON-friendly payload for the 155 168 * `response` column. WP_Error gets unpacked into code/message/data so … … 157 170 * scalars are JSON-encoded as-is. 158 171 * 159 * @param mixed $result The send result (bool, array, or WP_Error). 172 * The gateway's saved secrets (its `password` fields) are scrubbed from 173 * the payload, since some providers echo credentials back in responses. 174 * 175 * @param mixed $result The send result (bool, array, or WP_Error). 176 * @param GatewayInterface|false $gateway The gateway that sent it. 160 177 * 161 178 * @return array|string|null 162 179 */ 163 private function encode_response( $result ) {180 private function encode_response( $result, $gateway ) { 164 181 if ( is_wp_error( $result ) ) { 165 return[182 $result = [ 166 183 'code' => $result->get_error_code(), 167 184 'message' => $result->get_error_message(), … … 170 187 } 171 188 189 if ( $gateway instanceof GatewayInterface ) { 190 $result = Secrets::redact( $result, Secrets::values( $gateway ) ); 191 } 192 172 193 return $result; 173 194 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)