Beispiel #1
0
def buildMissingRooms():
    sysSettings = settings.query.first()
    channelQuery = Channel.Channel.query.all()
    for channel in channelQuery:
        try:
            xmppQuery = ejabberd.get_room_affiliations(
                channel.channelLoc, 'conference.' + sysSettings.siteAddress)
        except:
            print({
                "level":
                "info",
                "message":
                "Rebuilding missing ejabberd room - " + str(channel.channelLoc)
            })
            ejabberd.create_room(channel.channelLoc,
                                 'conference.' + sysSettings.siteAddress,
                                 sysSettings.siteAddress)

            for key, value in room_config.items():
                ejabberd.change_room_option(
                    channel.channelLoc,
                    'conference.' + sysSettings.siteAddress, key, value)

            ejabberd.set_room_affiliation(
                channel.channelLoc, 'conference.' + sysSettings.siteAddress,
                channel.owner.uuid + '@' + sysSettings.siteAddress, 'owner')

    return True
Beispiel #2
0
    def post(self):
        """
            Creates a New Channel
        """
        if 'X-API-KEY' in request.headers:
            requestAPIKey = apikey.apikey.query.filter_by(key=request.headers['X-API-KEY']).first()
            if requestAPIKey is not None:
                if requestAPIKey.isValid():
                    args = channelParserPost.parse_args()
                    newChannel = Channel.Channel(int(requestAPIKey.userID), str(uuid.uuid4()), args['channelName'], int(args['topicID']), args['recordEnabled'], args['chatEnabled'], args['commentsEnabled'], args['description'])

                    userQuery = Sec.User.query.filter_by(id=int(requestAPIKey.userID)).first()

                    # Establish XMPP Channel
                    from app import ejabberd
                    sysSettings = settings.settings.query.all()[0]
                    ejabberd.create_room(newChannel.channelLoc, 'conference.' + sysSettings.siteAddress, sysSettings.siteAddress)
                    ejabberd.set_room_affiliation(newChannel.channelLoc, 'conference.' + sysSettings.siteAddress, int(requestAPIKey.userID) + "@" + sysSettings.siteAddress, "owner")

                    # Default values
                    for key, value in globalvars.room_config.items():
                        ejabberd.change_room_option(newChannel.channelLoc, 'conference.' + sysSettings.siteAddress, key, value)

                    # Name and title
                    ejabberd.change_room_option(newChannel.channelLoc, 'conference.' + sysSettings.siteAddress, 'title', newChannel.channelName)
                    ejabberd.change_room_option(newChannel.channelLoc, 'conference.' + sysSettings.siteAddress, 'description', userQuery.username + 's chat room for the channel "' + newChannel.channelName + '"')

                    db.session.add(newChannel)
                    db.session.commit()

                    return {'results': {'message':'Channel Created', 'apiKey':newChannel.streamKey}}, 200
        return {'results': {'message':"Request Error"}}, 400
def buildMissingRooms():
    sysSettings = settings.query.first()
    channelQuery = Channel.Channel.query.all()
    for channel in channelQuery:
        try:
            xmppQuery = ejabberd.get_room_affiliations(
                channel.channelLoc, 'conference.' + sysSettings.siteAddress)
        except:
            ejabberd.create_room(channel.channelLoc,
                                 'conference.' + sysSettings.siteAddress,
                                 sysSettings.siteAddress)

            for key, value in room_config.items():
                ejabberd.change_room_option(
                    channel.channelLoc,
                    'conference.' + sysSettings.siteAddress, key, value)

            ejabberd.set_room_affiliation(
                channel.channelLoc, 'conference.' + sysSettings.siteAddress,
                channel.owner.username + '@' + sysSettings.siteAddress,
                'owner')

    return True