Search in sources :

Example 1 with ChannelChatRole

use of net.iGap.module.enums.ChannelChatRole 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);
            }
        }
    });
}
Also used : ChannelChatRole(net.iGap.module.enums.ChannelChatRole) GroupChatRole(net.iGap.module.enums.GroupChatRole)

Example 2 with ChannelChatRole

use of net.iGap.module.enums.ChannelChatRole in project iGap-Android by KianIranian-STDG.

the class RealmChannelRoom method detectMemberRole.

public static ChannelChatRole detectMemberRole(long roomId, long messageSenderId) {
    return DbManager.getInstance().doRealmTask(realm -> {
        ChannelChatRole role = ChannelChatRole.UNRECOGNIZED;
        RealmRoom realmRoom = realm.where(RealmRoom.class).equalTo("id", roomId).findFirst();
        if (realmRoom != null) {
            if (realmRoom.getChannelRoom() != null) {
                RealmList<RealmMember> realmMembers = realmRoom.getChannelRoom().getMembers();
                for (RealmMember realmMember : realmMembers) {
                    if (realmMember.getPeerId() == messageSenderId) {
                        role = ChannelChatRole.valueOf(realmMember.getRole());
                    }
                }
            }
        }
        return role;
    });
}
Also used : ChannelChatRole(net.iGap.module.enums.ChannelChatRole)

Aggregations

ChannelChatRole (net.iGap.module.enums.ChannelChatRole)2 GroupChatRole (net.iGap.module.enums.GroupChatRole)1