Skip to content

Commit 1863f6f

Browse files
KMchaudharyKMchaudhary
andauthored
Fix the email, firstname, lastname 0 value passed to transcoding request (#1538)
Co-authored-by: KMchaudhary <kuldipkumar.chaudhary@rtcamp.com>
1 parent 3a85868 commit 1863f6f

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

admin/class-rtgodam-transcoder-handler.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,16 @@ public function wp_media_transcoding( $wp_metadata, $attachment_id, $autoformat
348348
// Get author name with fallback to username.
349349
$author_first_name = '';
350350
$author_last_name = '';
351+
$author_email = '';
351352

352353
if ( $attachment_author ) {
353-
$author_first_name = $attachment_author->first_name;
354-
$author_last_name = $attachment_author->last_name;
354+
$author_first_name = $attachment_author->first_name ?? '';
355+
$author_last_name = $attachment_author->last_name ?? '';
356+
$author_email = $attachment_author->user_email ?? '';
355357

356358
// If first and last names are empty, use username as fallback.
357359
if ( empty( $author_first_name ) && empty( $author_last_name ) ) {
358-
$author_first_name = $attachment_author->user_login;
360+
$author_first_name = $attachment_author->user_login ?? '';
359361
}
360362
}
361363

@@ -379,7 +381,7 @@ public function wp_media_transcoding( $wp_metadata, $attachment_id, $autoformat
379381
'watermark' => boolval( $rtgodam_watermark ),
380382
'resolutions' => array( 'auto' ),
381383
'video_quality' => $rtgodam_video_compress_quality,
382-
'wp_author_email' => apply_filters( 'godam_author_email_to_send', $attachment_author ? $attachment_author->user_email : '', $attachment_id ),
384+
'wp_author_email' => apply_filters( 'godam_author_email_to_send', $author_email, $attachment_id ),
383385
'wp_site' => $site_url,
384386
'wp_author_first_name' => apply_filters( 'godam_author_first_name_to_send', $author_first_name, $attachment_id ),
385387
'wp_author_last_name' => apply_filters( 'godam_author_last_name_to_send', $author_last_name, $attachment_id ),

inc/classes/class-media-library-ajax.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,16 @@ public function upload_media_to_frappe_backend( $attachment_id, $retranscode = f
218218
// Get author name with fallback to username.
219219
$author_first_name = '';
220220
$author_last_name = '';
221+
$author_email = '';
221222

222223
if ( $attachment_author ) {
223-
$author_first_name = $attachment_author->first_name;
224-
$author_last_name = $attachment_author->last_name;
224+
$author_first_name = $attachment_author->first_name ?? '';
225+
$author_last_name = $attachment_author->last_name ?? '';
226+
$author_email = $attachment_author->user_email ?? '';
225227

226228
// If first and last names are empty, use username as fallback.
227229
if ( empty( $author_first_name ) && empty( $author_last_name ) ) {
228-
$author_first_name = $attachment_author->user_login;
230+
$author_first_name = $attachment_author->user_login ?? '';
229231
}
230232
}
231233

@@ -251,7 +253,7 @@ public function upload_media_to_frappe_backend( $attachment_id, $retranscode = f
251253
'orignal_file_name' => $file_name ?? $file_title,
252254
'callback_url' => rawurlencode( $callback_url ),
253255
'status_callback' => rawurlencode( $status_callback_url ),
254-
'wp_author_email' => apply_filters( 'godam_author_email_to_send', $attachment_author ? $attachment_author->user_email : '', $attachment_id ),
256+
'wp_author_email' => apply_filters( 'godam_author_email_to_send', $author_email, $attachment_id ),
255257
'wp_site' => $site_url,
256258
'wp_author_first_name' => apply_filters( 'godam_author_first_name_to_send', $author_first_name, $attachment_id ),
257259
'wp_author_last_name' => apply_filters( 'godam_author_last_name_to_send', $author_last_name, $attachment_id ),

inc/helpers/custom-functions.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,13 @@ function rtgodam_send_video_to_godam_for_transcoding( $form_type = '', $form_tit
524524
$site_url = get_site_url();
525525

526526
// Get author name with fallback to username.
527-
$author_first_name = $current_user->first_name;
528-
$author_last_name = $current_user->last_name;
527+
$author_first_name = $current_user->first_name ?? '';
528+
$author_last_name = $current_user->last_name ?? '';
529+
$author_email = $current_user->user_email ?? '';
529530

530531
// If first and last names are empty, use username as fallback.
531532
if ( empty( $author_first_name ) && empty( $author_last_name ) ) {
532-
$author_first_name = $current_user->user_login;
533+
$author_first_name = $current_user->user_login ?? '';
533534
}
534535

535536
$body = array_merge(
@@ -547,7 +548,7 @@ function rtgodam_send_video_to_godam_for_transcoding( $form_type = '', $form_tit
547548
'watermark' => boolval( $rtgodam_watermark ),
548549
'resolutions' => array( 'auto' ),
549550
'folder_name' => ! empty( $form_title ) ? $form_title : __( 'Gravity forms', 'godam' ),
550-
'wp_author_email' => apply_filters( 'godam_author_email_to_send', $current_user->user_email, 0 ),
551+
'wp_author_email' => apply_filters( 'godam_author_email_to_send', $author_email, 0 ),
551552
'wp_site' => $site_url,
552553
'wp_author_first_name' => apply_filters( 'godam_author_first_name_to_send', $author_first_name, 0 ),
553554
'wp_author_last_name' => apply_filters( 'godam_author_last_name_to_send', $author_last_name, 0 ),

0 commit comments

Comments
 (0)