diff --git a/app/src/main/java/eu/droogers/smsmatrix/Matrix.java b/app/src/main/java/eu/droogers/smsmatrix/Matrix.java index 93481fc..3f5a09d 100644 --- a/app/src/main/java/eu/droogers/smsmatrix/Matrix.java +++ b/app/src/main/java/eu/droogers/smsmatrix/Matrix.java @@ -254,15 +254,27 @@ public class Matrix { Room room = store.getRoom(event.roomId); SmsManager smsManager = SmsManager.getDefault(); JsonObject json = event.getContent().getAsJsonObject(); + + if (event.type.equals("m.room.message")) { - if (json.get("msgtype").getAsString().equals(MESSAGE_TYPE_TEXT)) { - String body = json.get("body").getAsString(); - smsManager.sendTextMessage(room.getTopic(), null, body, null, null); + if (json.get("msgtype").getAsString().equals(MESSAGE_TYPE_TEXT)) { + String body = json.get("body").getAsString(); + smsManager.sendTextMessage(room.getTopic(), null, body, null, null); + } else { + String url = session.getContentManager().getDownloadableUrl(json.get("url").getAsString()); + smsManager.sendTextMessage(room.getTopic(), null, url, null, null); + } + } else if (event.type.equals("m.room.member")) { + if (json.get("membership").getAsString().equals("leave")) { + room.leave(new SimpleApiCallback()); + } else if (json.get("membership").getAsString().equals("invite")) { + room.join(new SimpleApiCallback()); + } } else { - String url = session.getContentManager().getDownloadableUrl(json.get("url").getAsString()); - smsManager.sendTextMessage(room.getTopic(), null, url, null, null); + Log.e(TAG, "sendEvent: Event type not supported "); } + room.markAllAsRead(new SimpleApiCallback()); } }