view libervia/server/restricted_bridge.py @ 1331:fe353fceec38

browser (invitation, photos/album): invitation manager improvments: invitation manager has been moved to a separated module, it is generic so it can be used with other activities. It has been simplified, and contact to add are dynamically filtered using a text input. Invitation are done by email using a the new modal. New notification module is used to indicate when invitation has been done.
author Goffi <goffi@goffi.org>
date Fri, 14 Aug 2020 09:31:32 +0200
parents ed28ad7d484c
children a32f3f47e4a8
line wrap: on
line source

#!/usr/bin/env python3

# Libervia: a SàT frontend
# Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from libervia.server.constants import Const as C


class RestrictedBridge:
    """Bridge with limited access, which can be used in browser

    Only a few method are implemented, with potentially dangerous argument controlled.
    Security limit is used
    """

    def __init__(self, host):
        self.host = host
        self.security_limit = C.SECURITY_LIMIT

    async def getContacts(self, profile):
        return await self.host.bridgeCall("getContacts", profile)

    async def identityGet(self, entity, metadata_filter, use_cache, profile):
        return await self.host.bridgeCall(
            "identityGet", entity, metadata_filter, use_cache, profile)

    async def identitiesGet(self, entities, metadata_filter, profile):
        return await self.host.bridgeCall(
            "identitiesGet", entities, metadata_filter, profile)

    async def identitiesBaseGet(self, profile):
        return await self.host.bridgeCall(
            "identitiesBaseGet", profile)

    async def fileHTTPUploadGetSlot(
        self, filename, size, content_type, upload_jid, profile):
        return await self.host.bridgeCall(
            "fileHTTPUploadGetSlot", filename, size, content_type,
            upload_jid, profile)

    async def fileSharingDelete(
        self, service_jid, path, namespace, profile):
        return await self.host.bridgeCall(
            "fileSharingDelete", service_jid, path, namespace, profile)

    async def interestRetract(
        self, service_jid, item_id, profile
    ):
        return await self.host.bridgeCall(
            "interestRetract", service_jid, item_id, profile)

    async def FISInvite(
        self, invitee_jid_s, service_s, repos_type, namespace, path, name, extra_s,
        profile
    ):
        return await self.host.bridgeCall(
            "FISInvite", invitee_jid_s, service_s, repos_type, namespace, path, name,
            extra_s, profile
        )

    async def FISAffiliationsSet(
        self, service_s, namespace, path, affiliations, profile
    ):
        return await self.host.bridgeCall(
            "FISAffiliationsSet", service_s, namespace, path, affiliations, profile
        )

    async def invitationSimpleCreate(
        self, invitee_email, invitee_name, url_template, extra_s, profile
    ):
        return await self.host.bridgeCall(
            "invitationSimpleCreate", invitee_email, invitee_name, url_template, extra_s,
            profile
        )