From 8c7e64991b6c05d57aaa8dda2df2dc53d789d6c4 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 7 Feb 2021 08:29:09 +0100 Subject: Dont download video with --no-video option, ignore events with state_key set if the event is not a m.room.member type --- src/plugins/Matrix.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 3a2c02c..9a785b6 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -1732,9 +1732,17 @@ namespace QuickMedia { if(!sender_json->IsString()) return nullptr; + const rapidjson::Value &type_json = GetMember(event_item_json, "type"); + if(!type_json.IsString()) + return nullptr; + bool sent_by_somebody_else = false; const rapidjson::Value *state_key_json = &GetMember(event_item_json, "state_key"); if(state_key_json->IsString() && state_key_json->GetStringLength() != 0) { + if(strcmp(type_json.GetString(), "m.room.member") != 0) { + fprintf(stderr, "Matrix: received state key %s but event type is %s, expected m.room.member\n", type_json.GetString(), state_key_json->GetString()); + return nullptr; + } if(strcmp(sender_json->GetString(), state_key_json->GetString()) != 0) sent_by_somebody_else = true; sender_json = state_key_json; @@ -1768,10 +1776,6 @@ namespace QuickMedia { if(origin_server_ts.IsInt64()) timestamp = origin_server_ts.GetInt64(); - const rapidjson::Value &type_json = GetMember(event_item_json, "type"); - if(!type_json.IsString()) - return nullptr; - bool provisional = false; const rapidjson::Value &unsigned_json = GetMember(event_item_json, "unsigned"); if(unsigned_json.IsObject()) { -- cgit v1.2.3