| @@ -207,9 +207,15 @@ | ||
| 207 | 207 | if ( 'user' !== $row['principal_type'] || (int) $row['principal_ref'] !== $user_id ) { |
| 208 | 208 | return new WP_Error( 'openstation_files_share_not_recipient', __( 'This invite is not for you.', 'desktop-mode' ), array( 'status' => 403 ) ); |
| 209 | 209 | } |
| 210 | 210 | if ( 'accepted' === $row['state'] ) { |
| 211 | - return $row; | |
| 211 | + // A previous attempt may have accepted the invite but failed to plant | |
| 212 | + // its tile (for example, a busy upload lock). Allow that step to retry. | |
| 213 | + $tables = openstation_files_table_names(); | |
| 214 | + $placed = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$tables['placements']} WHERE owner_id = %d AND file_type = 'upload' AND file_ref = %s LIMIT 1", $user_id, (string) $row['folder_id'] ) ); | |
| 215 | + if ( $placed ) { | |
| 216 | + return $row; | |
| 217 | + } | |
| 212 | 218 | } |
| 213 | 219 | if ( 'denied' === $row['state'] ) { |
| 214 | 220 | return new WP_Error( 'openstation_files_share_already_denied', __( 'This invite was denied.', 'desktop-mode' ), array( 'status' => 410 ) ); |
| 215 | 221 | } |
| @@ -230,9 +236,12 @@ | ||
| 230 | 236 | // `can_read` gate sees the accepted share. |
| 231 | 237 | $file_id = (int) $row['folder_id']; |
| 232 | 238 | /** This filter is documented in includes/desktop-files/shares-store.php */ |
| 233 | 239 | $parent_id = (int) apply_filters( 'openstation_folder_share_accept_default_parent', 0, $file_id, $user_id, $row ); |
| 234 | - openstation_files_place_at_next_free_slot( $user_id, $parent_id, 'upload', (string) $file_id ); | |
| 240 | + $placed = openstation_files_place_at_next_free_slot( $user_id, $parent_id, 'upload', (string) $file_id ); | |
| 241 | + if ( is_wp_error( $placed ) ) { | |
| 242 | + return $placed; | |
| 243 | + } | |
| 235 | 244 | |
| 236 | 245 | $next = openstation_files_get_share( $share_id ); |
| 237 | 246 | |
| 238 | 247 | /** This action is documented in includes/desktop-files/shares-store.php */ |
| @@ -486,14 +495,14 @@ | ||
| 486 | 495 | if ( $file ) { |
| 487 | 496 | $shape['fileName'] = (string) $file['display_name']; |
| 488 | 497 | $shape['ownerId'] = (int) $file['owner_id']; |
| 489 | 498 | $owner = get_userdata( (int) $file['owner_id'] ); |
| 490 | - $shape['ownerName'] = $owner ? $owner->display_name : ''; | |
| 499 | + $shape['ownerName'] = $owner ? openstation_plain_text_title( $owner->display_name ) : ''; | |
| 491 | 500 | $shape['ownerAvatar'] = $owner ? get_avatar_url( $owner->ID, array( 'size' => 48 ) ) : ''; |
| 492 | 501 | } |
| 493 | 502 | // Principal enrichment for the owner-side share list. |
| 494 | 503 | $principal = get_userdata( (int) $row['principal_ref'] ); |
| 495 | - $shape['displayName'] = $principal ? $principal->display_name : ''; | |
| 504 | + $shape['displayName'] = $principal ? openstation_plain_text_title( $principal->display_name ) : ''; | |
| 496 | 505 | $shape['avatarUrl'] = $principal ? get_avatar_url( $principal->ID, array( 'size' => 48 ) ) : ''; |
| 497 | 506 | return $shape; |
| 498 | 507 | } |
| 499 | 508 | |