| 6059 | return false; | 6059 | return false; |
| 6060 | } | 6060 | } |
| 6061 | // If swipes structure is invalid, exit out | 6061 | // If swipes structure is invalid, exit out |
| 6062 | if (!Array.isArray(targetMessage.swipe_info) || !Array.isArray(targetMessage.swipes)) { | 6062 | if (!Array.isArray(targetMessage.swipes)) { |
| 6063 | return false; | 6063 | return false; |
| 6064 | } | 6064 | } |
| 6065 | | 6065 | |
| | 6066 | // Backfill swipe_info if missing. |
| | 6067 | if (!Array.isArray(targetMessage.swipe_info)) { |
| | 6068 | targetMessage.swipe_info = targetMessage.swipes.map(_ => ({ |
| | 6069 | send_date: targetMessage.send_date, |
| | 6070 | gen_started: void 0, |
| | 6071 | gen_finished: void 0, |
| | 6072 | extra: {}, |
| | 6073 | })); |
| | 6074 | } |
| | 6075 | |
| 6066 | const targetSwipeId = targetMessage.swipe_id; | 6076 | const targetSwipeId = targetMessage.swipe_id; |
| 6067 | if (typeof targetMessage.swipes[targetSwipeId] !== 'string') { | 6077 | if (typeof targetMessage.swipes[targetSwipeId] !== 'string') { |
| 6068 | console.warn(`[syncSwipeToMes] Invalid swipe ID: ${targetSwipeId}`); | 6078 | console.warn(`[syncSwipeToMes] Invalid swipe ID: ${targetSwipeId}`); |
| 6069 | return false; | 6079 | return false; |
| 6070 | } | 6080 | } |
| 6071 | | 6081 | |
| 6072 | const targetSwipeInfo = targetMessage?.swipe_info[targetSwipeId]; | 6082 | const targetSwipeInfo = targetMessage?.swipe_info?.[targetSwipeId]; |
| 6073 | if (typeof targetSwipeInfo !== 'object') { | 6083 | if (typeof targetSwipeInfo !== 'object') { |
| 6074 | console.warn(`[syncSwipeToMes] Invalid swipe info: ${targetSwipeId}`); | 6084 | console.warn(`[syncSwipeToMes] Invalid swipe info: ${targetSwipeId}`); |
| 6075 | } | 6085 | } |