| @@ -204,9 +204,16 @@ | ||
| 204 | 204 | */ |
| 205 | 205 | public function delete_conversation( $conversation_id ) { |
| 206 | 206 | $userid = WPF()->current_userid; |
| 207 | 207 | |
| 208 | - // Delete messages first | |
| 208 | + // SECURITY: Verify ownership before deleting anything | |
| 209 | + // get_conversation() returns null if conversation doesn't belong to current user | |
| 210 | + $conversation = $this->get_conversation( $conversation_id ); | |
| 211 | + if ( ! $conversation ) { | |
| 212 | + return false; | |
| 213 | + } | |
| 214 | + | |
| 215 | + // Delete messages first (now safe - ownership verified above) | |
| 209 | 216 | $messages_table = WPF()->tables->ai_chat_messages; |
| 210 | 217 | WPF()->db->delete( |
| 211 | 218 | $messages_table, |
| 212 | 219 | [ 'conversation_id' => $conversation_id ], |