feat_: accept community join request with mvds (#5787)
* feat_: accept community join request with mvds * chore_: no sender when use mvds in comm join response * fix_: only use mvds for tokenized communities * chore_: add comment for this.
This commit is contained in:
parent
ea290d97ef
commit
1b53d04ccf
|
@ -65,6 +65,7 @@ type RawMessage struct {
|
|||
// don't wrap message into ProtocolMessage.
|
||||
// when this is true, the message will not be resent via ResendTypeDataSync, but it's possible to
|
||||
// resend it via ResendTypeRawMessage specified in ResendType
|
||||
// MVDS only supports sending encrypted message.
|
||||
SkipEncryptionLayer bool
|
||||
SendPushNotification bool
|
||||
MessageType protobuf.ApplicationMetadataMessage_Type
|
||||
|
|
|
@ -3520,6 +3520,7 @@ func (m *Manager) HandleCommunityRequestToJoinResponse(signer *ecdsa.PublicKey,
|
|||
|
||||
isControlNodeSigner := common.IsPubKeyEqual(community.ControlNode(), signer)
|
||||
if !isControlNodeSigner {
|
||||
m.logger.Debug("signer is not control node", zap.String("signer", common.PubkeyToHex(signer)), zap.String("controlNode", common.PubkeyToHex(community.ControlNode())))
|
||||
return nil, ErrNotAuthorized
|
||||
}
|
||||
|
||||
|
|
|
@ -1953,6 +1953,10 @@ func (m *Messenger) CancelRequestToJoinCommunity(ctx context.Context, request *r
|
|||
}
|
||||
|
||||
func (m *Messenger) acceptRequestToJoinCommunity(requestToJoin *communities.RequestToJoin) (*MessengerResponse, error) {
|
||||
m.logger.Debug("accept request to join community",
|
||||
zap.String("community", requestToJoin.CommunityID.String()),
|
||||
zap.String("pubkey", requestToJoin.PublicKey))
|
||||
|
||||
community, err := m.communitiesManager.AcceptRequestToJoin(requestToJoin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -2021,6 +2025,16 @@ func (m *Messenger) acceptRequestToJoinCommunity(requestToJoin *communities.Requ
|
|||
Priority: &common.HighPriority,
|
||||
}
|
||||
|
||||
// Non-tokenized community treat community public key as the control node,
|
||||
// tokenized community set control node to the public key of token owner.
|
||||
// MVDS doesn't support custom sender, and use the identity key for signing messages,
|
||||
// receiver will verify the message of community join response is signed by control node.
|
||||
if !community.PublicKey().Equal(community.ControlNode()) {
|
||||
rawMessage.ResendType = common.ResendTypeDataSync
|
||||
rawMessage.SkipEncryptionLayer = false
|
||||
rawMessage.Sender = nil
|
||||
}
|
||||
|
||||
if community.Encrypted() {
|
||||
rawMessage.HashRatchetGroupID = community.ID()
|
||||
rawMessage.CommunityKeyExMsgType = common.KeyExMsgReuse
|
||||
|
@ -2031,10 +2045,12 @@ func (m *Messenger) acceptRequestToJoinCommunity(requestToJoin *communities.Requ
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if rawMessage.ResendType == common.ResendTypeRawMessage {
|
||||
if _, err = m.AddRawMessageToWatch(rawMessage); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response := &MessengerResponse{}
|
||||
response.AddCommunity(community)
|
||||
|
|
Loading…
Reference in New Issue