mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-13 19:38:47 +00:00
core, ui: invite member of one group to another group (#7682)
* rfc: invite member of one group to another group * update * update * implement * version * update * do not show error if contact was removed when joining group --------- Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
co-authored by
Evgeny @ SimpleX Chat
parent
1053e9fb5c
commit
07c363849b
@@ -351,6 +351,23 @@ class ChatApi:
|
||||
return r["member"]
|
||||
raise ChatCommandError("error adding member", r)
|
||||
|
||||
async def api_add_member_via_group(
|
||||
self, group_id: int, via_group_id: int, group_member_id: int, member_role: T.GroupMemberRole
|
||||
) -> T.GroupMember:
|
||||
r = await self.send_chat_cmd(
|
||||
CC.APIAddMemberViaGroup_cmd_string(
|
||||
{
|
||||
"groupId": group_id,
|
||||
"viaGroupId": via_group_id,
|
||||
"groupMemberId": group_member_id,
|
||||
"memberRole": member_role,
|
||||
}
|
||||
)
|
||||
)
|
||||
if r["type"] == "sentGroupInvitationViaGroup":
|
||||
return r["member"]
|
||||
raise ChatCommandError("error adding member", r)
|
||||
|
||||
async def api_join_group(self, group_id: int) -> T.GroupInfo:
|
||||
r = await self.send_chat_cmd(CC.APIJoinGroup_cmd_string({"groupId": group_id}))
|
||||
if r["type"] == "userAcceptedGroupSent":
|
||||
|
||||
@@ -235,6 +235,21 @@ def APIAddMember_cmd_string(self: APIAddMember) -> str:
|
||||
APIAddMember_Response = CR.SentGroupInvitation | CR.ChatCmdError
|
||||
|
||||
|
||||
# Add member of another group to group. Requires bot to have Admin role in the group, and direct messages allowed for its role in another group.
|
||||
# Network usage: interactive.
|
||||
class APIAddMemberViaGroup(TypedDict):
|
||||
groupId: int # int64
|
||||
viaGroupId: int # int64
|
||||
groupMemberId: int # int64
|
||||
memberRole: "T.GroupMemberRole"
|
||||
|
||||
|
||||
def APIAddMemberViaGroup_cmd_string(self: APIAddMemberViaGroup) -> str:
|
||||
return '/_add #' + str(self['groupId']) + ' #' + str(self['viaGroupId']) + ' ' + str(self['groupMemberId']) + ' ' + str(self['memberRole'])
|
||||
|
||||
APIAddMemberViaGroup_Response = CR.SentGroupInvitationViaGroup | CR.ChatCmdError
|
||||
|
||||
|
||||
# Join group.
|
||||
# Network usage: interactive.
|
||||
class APIJoinGroup(TypedDict):
|
||||
|
||||
@@ -84,6 +84,15 @@ class ReceivedGroupInvitation(TypedDict):
|
||||
fromMemberRole: "T.GroupMemberRole"
|
||||
memberRole: "T.GroupMemberRole"
|
||||
|
||||
class ReceivedGroupInvitationViaGroup(TypedDict):
|
||||
type: Literal["receivedGroupInvitationViaGroup"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
viaGroupInfo: "T.GroupInfo"
|
||||
viaMember: "T.GroupMember"
|
||||
fromMemberRole: "T.GroupMemberRole"
|
||||
memberRole: "T.GroupMemberRole"
|
||||
|
||||
class UserJoinedGroup(TypedDict):
|
||||
type: Literal["userJoinedGroup"]
|
||||
user: "T.User"
|
||||
@@ -352,6 +361,7 @@ ChatEvent = (
|
||||
| GroupChatItemsDeleted
|
||||
| ChatItemsStatusesUpdated
|
||||
| ReceivedGroupInvitation
|
||||
| ReceivedGroupInvitationViaGroup
|
||||
| UserJoinedGroup
|
||||
| GroupUpdated
|
||||
| JoinedGroupMember
|
||||
@@ -394,7 +404,7 @@ ChatEvent = (
|
||||
| ChatErrors
|
||||
)
|
||||
|
||||
ChatEvent_Tag = Literal["contactConnected", "contactUpdated", "contactDeletedByContact", "receivedContactRequest", "newMemberContactReceivedInv", "contactSndReady", "newChatItems", "chatItemReaction", "chatItemsDeleted", "chatItemUpdated", "groupChatItemsDeleted", "chatItemsStatusesUpdated", "receivedGroupInvitation", "userJoinedGroup", "groupUpdated", "joinedGroupMember", "memberRole", "deletedMember", "leftMember", "deletedMemberUser", "groupDeleted", "connectedToGroupMember", "memberAcceptedByOther", "memberBlockedForAll", "groupMemberUpdated", "groupLinkDataUpdated", "groupRelayUpdated", "rcvFileDescrReady", "rcvFileComplete", "sndFileCompleteXFTP", "rcvFileStart", "rcvFileSndCancelled", "rcvFileAccepted", "rcvFileError", "rcvFileWarning", "sndFileError", "sndFileWarning", "acceptingContactRequest", "acceptingBusinessRequest", "contactConnecting", "businessLinkConnecting", "joinedGroupMemberConnecting", "groupLinkConnecting", "hostConnected", "hostDisconnected", "subscriptionStatus", "serviceRequest", "serviceReplySent", "remoteCtrlSessionCode", "remoteCtrlStopped", "messageError", "chatError", "chatErrors"]
|
||||
ChatEvent_Tag = Literal["contactConnected", "contactUpdated", "contactDeletedByContact", "receivedContactRequest", "newMemberContactReceivedInv", "contactSndReady", "newChatItems", "chatItemReaction", "chatItemsDeleted", "chatItemUpdated", "groupChatItemsDeleted", "chatItemsStatusesUpdated", "receivedGroupInvitation", "receivedGroupInvitationViaGroup", "userJoinedGroup", "groupUpdated", "joinedGroupMember", "memberRole", "deletedMember", "leftMember", "deletedMemberUser", "groupDeleted", "connectedToGroupMember", "memberAcceptedByOther", "memberBlockedForAll", "groupMemberUpdated", "groupLinkDataUpdated", "groupRelayUpdated", "rcvFileDescrReady", "rcvFileComplete", "sndFileCompleteXFTP", "rcvFileStart", "rcvFileSndCancelled", "rcvFileAccepted", "rcvFileError", "rcvFileWarning", "sndFileError", "sndFileWarning", "acceptingContactRequest", "acceptingBusinessRequest", "contactConnecting", "businessLinkConnecting", "joinedGroupMemberConnecting", "groupLinkConnecting", "hostConnected", "hostDisconnected", "subscriptionStatus", "serviceRequest", "serviceReplySent", "remoteCtrlSessionCode", "remoteCtrlStopped", "messageError", "chatError", "chatErrors"]
|
||||
|
||||
|
||||
class OnEventDecorator(Protocol):
|
||||
@@ -483,6 +493,12 @@ class OnEventDecorator(Protocol):
|
||||
Callable[["ReceivedGroupInvitation"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["receivedGroupInvitationViaGroup"], /) -> Callable[
|
||||
[Callable[["ReceivedGroupInvitationViaGroup"], Awaitable[None]]],
|
||||
Callable[["ReceivedGroupInvitationViaGroup"], Awaitable[None]],
|
||||
]: ...
|
||||
|
||||
@overload
|
||||
def __call__(self, event: Literal["userJoinedGroup"], /) -> Callable[
|
||||
[Callable[["UserJoinedGroup"], Awaitable[None]]],
|
||||
|
||||
@@ -264,6 +264,14 @@ class SentGroupInvitation(TypedDict):
|
||||
contact: "T.Contact"
|
||||
member: "T.GroupMember"
|
||||
|
||||
class SentGroupInvitationViaGroup(TypedDict):
|
||||
type: Literal["sentGroupInvitationViaGroup"]
|
||||
user: "T.User"
|
||||
groupInfo: "T.GroupInfo"
|
||||
member: "T.GroupMember"
|
||||
viaGroupInfo: "T.GroupInfo"
|
||||
viaMember: "T.GroupMember"
|
||||
|
||||
class SentInvitation(TypedDict):
|
||||
type: Literal["sentInvitation"]
|
||||
user: "T.User"
|
||||
@@ -402,6 +410,7 @@ ChatResponse = (
|
||||
| RemoteCtrlConnecting
|
||||
| SentConfirmation
|
||||
| SentGroupInvitation
|
||||
| SentGroupInvitationViaGroup
|
||||
| SentInvitation
|
||||
| SentInvitationToContact
|
||||
| ServiceReplyAccepted
|
||||
@@ -420,4 +429,4 @@ ChatResponse = (
|
||||
| ApiChats
|
||||
)
|
||||
|
||||
ChatResponse_Tag = Literal["acceptingContactRequest", "activeUser", "chatItemNotChanged", "chatItemReaction", "chatItemUpdated", "chatItemsDeleted", "chatMsgContent", "chatRunning", "chatStarted", "chatStopped", "cmdOk", "chatCmdError", "connectionPlan", "contactAlreadyExists", "contactConnectionDeleted", "contactDeleted", "contactPrefsUpdated", "contactRequestRejected", "contactsList", "groupDeletedUser", "groupLink", "groupLinkCreated", "groupLinkDeleted", "groupCreated", "publicGroupCreated", "publicGroupCreationFailed", "groupRelays", "groupRelaysAdded", "groupRelaysAddFailed", "relayGroupAllowed", "groupMembers", "groupUpdated", "groupsList", "groupDomainVerified", "invitation", "leftMemberUser", "memberAccepted", "membersBlockedForAllUser", "membersRoleUser", "newChatItems", "rcvFileAccepted", "rcvFileAcceptedSndCancelled", "rcvFileCancelled", "remoteCtrlConnected", "remoteCtrlConnecting", "sentConfirmation", "sentGroupInvitation", "sentInvitation", "sentInvitationToContact", "serviceReplyAccepted", "sndFileCancelled", "startedConnectionToContact", "startedConnectionToGroup", "userAcceptedGroupSent", "userContactLink", "userContactLinkCreated", "userContactLinkDeleted", "userContactLinkUpdated", "userDeletedMembers", "userProfileUpdated", "userProfileNoChange", "usersList", "apiChats"]
|
||||
ChatResponse_Tag = Literal["acceptingContactRequest", "activeUser", "chatItemNotChanged", "chatItemReaction", "chatItemUpdated", "chatItemsDeleted", "chatMsgContent", "chatRunning", "chatStarted", "chatStopped", "cmdOk", "chatCmdError", "connectionPlan", "contactAlreadyExists", "contactConnectionDeleted", "contactDeleted", "contactPrefsUpdated", "contactRequestRejected", "contactsList", "groupDeletedUser", "groupLink", "groupLinkCreated", "groupLinkDeleted", "groupCreated", "publicGroupCreated", "publicGroupCreationFailed", "groupRelays", "groupRelaysAdded", "groupRelaysAddFailed", "relayGroupAllowed", "groupMembers", "groupUpdated", "groupsList", "groupDomainVerified", "invitation", "leftMemberUser", "memberAccepted", "membersBlockedForAllUser", "membersRoleUser", "newChatItems", "rcvFileAccepted", "rcvFileAcceptedSndCancelled", "rcvFileCancelled", "remoteCtrlConnected", "remoteCtrlConnecting", "sentConfirmation", "sentGroupInvitation", "sentGroupInvitationViaGroup", "sentInvitation", "sentInvitationToContact", "serviceReplyAccepted", "sndFileCancelled", "startedConnectionToContact", "startedConnectionToGroup", "userAcceptedGroupSent", "userContactLink", "userContactLinkCreated", "userContactLinkDeleted", "userContactLinkUpdated", "userDeletedMembers", "userProfileUpdated", "userProfileNoChange", "usersList", "apiChats"]
|
||||
|
||||
Reference in New Issue
Block a user