use of net.iGap.module.enums.GroupChatRole in project iGap-Android by KianIranian-STDG.
the class RealmGroupRoom method detectMemberRole.
public static GroupChatRole detectMemberRole(long roomId, long messageSenderId) {
return DbManager.getInstance().doRealmTask(realm -> {
GroupChatRole role = GroupChatRole.UNRECOGNIZED;
RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomId).findFirst();
if (realmRoom != null) {
if (realmRoom.getGroupRoom() != null) {
RealmList<RealmMember> realmMembers = realmRoom.getGroupRoom().getMembers();
for (RealmMember realmMember : realmMembers) {
if (realmMember.getPeerId() == messageSenderId) {
role = GroupChatRole.valueOf(realmMember.getRole());
}
}
}
}
return role;
});
}
use of net.iGap.module.enums.GroupChatRole in project iGap-Android by KianIranian-STDG.
the class RealmRoom method updateMineRole.
public static void updateMineRole(long roomId, long memberId, final String role) {
DbManager.getInstance().doRealmTransaction(realm -> {
if (memberId == AccountManager.getInstance().getCurrentUser().getId()) {
final RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomId).findFirst();
if (realmRoom == null) {
return;
}
if (realmRoom.getType() == ProtoGlobal.Room.Type.GROUP) {
GroupChatRole mRole;
if (role.contains(GroupChatRole.ADMIN.toString())) {
mRole = GroupChatRole.ADMIN;
} else if (role.contains(GroupChatRole.MODERATOR.toString())) {
mRole = GroupChatRole.MODERATOR;
} else {
mRole = GroupChatRole.MEMBER;
}
if (realmRoom.getGroupRoom() != null) {
realmRoom.getGroupRoom().setRole(mRole);
}
} else {
ChannelChatRole mRole;
if (role.contains(ChannelChatRole.ADMIN.toString())) {
mRole = ChannelChatRole.ADMIN;
} else if (role.contains(ChannelChatRole.MODERATOR.toString())) {
mRole = ChannelChatRole.MODERATOR;
} else {
mRole = ChannelChatRole.MEMBER;
}
if (realmRoom.getChannelRoom() != null) {
realmRoom.getChannelRoom().setRole(mRole);
}
updateReadOnlyChannel(mRole, realmRoom);
}
}
});
}
Aggregations