1
0
mirror of https://github.com/tijder/SmsMatrix.git synced 2024-10-27 18:24:01 +00:00

Join and Leave rooms

Join a room if invited by user
Leave the room when the user leaves
This commit is contained in:
untidylamp_gitlab 2018-11-01 17:35:50 -04:00 committed by GitHub
parent 4efdf09f7b
commit 38b6720a90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -255,6 +255,8 @@ public class Matrix {
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);
@ -262,6 +264,16 @@ public class Matrix {
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<Void>());
} else if (json.get("membership").getAsString().equals("invite")) {
room.join(new SimpleApiCallback<Void>());
}
} else {
Log.e(TAG, "sendEvent: Event type not supported ");
}
room.markAllAsRead(new SimpleApiCallback<Void>());
}