Fix state and room events
* State event descended from Event, but it is actually based on Room * Room events may have a missing room_id property due to HS * optimization
This commit is contained in:
parent
62eb4e7e21
commit
fcc592b072
@ -26,7 +26,9 @@ public abstract class Matrix.Event.Room : Matrix.Event.Base {
|
||||
public string? event_id { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* The ID of the room associated with this event. Required.
|
||||
* The ID of the room associated with this event. Required, but it
|
||||
* may be stripped by HS implementations from some APIs if they
|
||||
* reside under a key marked with the room ID.
|
||||
*/
|
||||
public string? room_id { get; set; default = null; }
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
public abstract class Matrix.Event.State : Matrix.Event.Base {
|
||||
public abstract class Matrix.Event.State : Matrix.Event.Room {
|
||||
protected string? _state_key;
|
||||
|
||||
public string? state_key {
|
||||
|
@ -115,6 +115,17 @@ public class Matrix.HTTPClient : Matrix.HTTPAPI, Matrix.Client {
|
||||
|
||||
if (evt != null) {
|
||||
string? user_id = null;
|
||||
GLib.Type evt_type = evt.get_type();
|
||||
|
||||
// Make sure Room events have room_id set, even if it was
|
||||
// stripped by the HS
|
||||
if (evt_type.is_a(typeof(Matrix.Event.Room))) {
|
||||
Matrix.Event.Room revt = (Matrix.Event.Room)evt;
|
||||
|
||||
if (revt.room_id == null) {
|
||||
revt.room_id = room_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (evt.get_type().is_a(typeof(Matrix.Event.Presence))) {
|
||||
var pevt = (Matrix.Event.Presence)evt;
|
||||
|
Loading…
Reference in New Issue
Block a user