2022-02-25 02:22:50 -05:00
|
|
|
# matrix-appservice-kakaotalk - A Matrix-KakaoTalk puppeting bridge.
|
|
|
|
# Copyright (C) 2022 Tulir Asokan, Andrew Ferrazzutti
|
|
|
|
#
|
|
|
|
# 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 <https://www.gnu.org/licenses/>.
|
|
|
|
"""
|
|
|
|
from .open_channel_info import *
|
|
|
|
from .open_channel import *
|
|
|
|
from .open_link_type import *
|
|
|
|
from .open_link_user_info import *
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2022-02-26 04:06:26 -05:00
|
|
|
from typing import TYPE_CHECKING, Optional, Union
|
2022-02-25 02:22:50 -05:00
|
|
|
|
|
|
|
from attr import dataclass
|
|
|
|
from enum import IntEnum
|
|
|
|
|
|
|
|
from mautrix.types import SerializableAttrs
|
|
|
|
|
|
|
|
from ..bson import Long
|
|
|
|
from .open_link_type import OpenLinkType
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from .open_link_user_info import OpenLinkUserInfo
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class OpenLinkComponent(SerializableAttrs):
|
|
|
|
linkId: Long
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class OpenTokenComponent(SerializableAttrs):
|
|
|
|
openToken: int
|
|
|
|
|
|
|
|
|
|
|
|
# Moved before OpenPrivilegeComponent which requires this
|
|
|
|
class KnownLinkPrivilegeMask(IntEnum):
|
|
|
|
URL_SHARABLE = 2
|
|
|
|
REPORTABLE = 4
|
|
|
|
PROFILE_EDITABLE = 8
|
|
|
|
ANY_PROFILE_ALLOWED = 32
|
|
|
|
USE_PASS_CODE = 64
|
|
|
|
BLINDABLE = 128
|
|
|
|
NON_SPECIAL_LINK = 512
|
|
|
|
USE_BOT = 1024
|
|
|
|
|
2022-02-26 04:06:26 -05:00
|
|
|
LinkPrivilegeMask = Union[KnownLinkPrivilegeMask, int, Long]
|
2022-02-25 02:22:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class OpenPrivilegeComponent(SerializableAttrs):
|
|
|
|
privilege: LinkPrivilegeMask
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(kw_only=True)
|
|
|
|
class OpenLinkSettings(SerializableAttrs):
|
|
|
|
linkName: str
|
2022-02-26 04:06:26 -05:00
|
|
|
linkCoverURL: Optional[str] = None
|
|
|
|
description: Optional[str] = None
|
2022-02-25 02:22:50 -05:00
|
|
|
searchable: bool
|
|
|
|
activated: bool
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class OpenLink(OpenLinkSettings, OpenLinkComponent, OpenTokenComponent, OpenPrivilegeComponent):
|
|
|
|
type: OpenLinkType
|
|
|
|
linkURL: str
|
|
|
|
openToken: int
|
|
|
|
linkOwner: "OpenLinkUserInfo"
|
|
|
|
profileTagList: list[str]
|
|
|
|
createdAt: int
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class OpenLinkChannelInfo(SerializableAttrs):
|
|
|
|
userLimit: int
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class OpenLinkProfileInfo(SerializableAttrs):
|
|
|
|
directLimit: int
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class OpenLinkInfo(OpenLinkChannelInfo, OpenLinkProfileInfo):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class InformedOpenLink(SerializableAttrs):
|
|
|
|
openLink: OpenLink
|
|
|
|
info: OpenLinkInfo
|
|
|
|
|
|
|
|
|
|
|
|
# KnownLinkPrivilegeMask and LinkPrivilegeMask moved from here
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(kw_only=True)
|
|
|
|
class OpenLinkUpdateTemplate(SerializableAttrs):
|
2022-02-26 04:06:26 -05:00
|
|
|
passcode: Optional[str] = None
|
2022-02-25 02:22:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass(kw_only=True)
|
|
|
|
class OpenLinkCreateTemplate(SerializableAttrs):
|
2022-02-26 04:06:26 -05:00
|
|
|
mainProfileOnly: Optional[bool] = None
|
2022-02-25 02:22:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class OpenLinkProfileTemplate(OpenLinkSettings, OpenLinkProfileInfo):
|
|
|
|
tags: str
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class OpenLinkChannelTemplate(OpenLinkSettings, OpenLinkChannelInfo):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = [
|
|
|
|
"OpenLinkComponent",
|
|
|
|
"OpenTokenComponent",
|
|
|
|
"KnownLinkPrivilegeMask",
|
|
|
|
"LinkPrivilegeMask",
|
|
|
|
"OpenPrivilegeComponent",
|
|
|
|
"OpenLinkSettings",
|
|
|
|
"OpenLink",
|
|
|
|
"OpenLinkChannelInfo",
|
|
|
|
"OpenLinkProfileInfo",
|
|
|
|
"OpenLinkInfo",
|
|
|
|
"InformedOpenLink",
|
|
|
|
"OpenLinkUpdateTemplate",
|
|
|
|
"OpenLinkCreateTemplate",
|
|
|
|
"OpenLinkProfileTemplate",
|
|
|
|
"OpenLinkChannelTemplate",
|
|
|
|
]
|