feat: mark automatic status updates as ephemeral

This commit is contained in:
Richard Ramos 2022-11-07 16:01:06 -04:00 committed by RichΛrd
parent f33c1cec38
commit 0f7c9f52d8
8 changed files with 11 additions and 0 deletions

View file

@ -103,6 +103,7 @@ func (w *gethPublicWakuAPIWrapper) Post(ctx context.Context, req types.NewMessag
PowTime: req.PowTime,
PowTarget: req.PowTarget,
TargetPeer: req.TargetPeer,
Ephemeral: req.Ephemeral,
}
return w.api.Post(ctx, msg)
}

View file

@ -95,6 +95,7 @@ func (w *gethPublicWakuV2APIWrapper) Post(ctx context.Context, req types.NewMess
Payload: req.Payload,
Padding: req.Padding,
TargetPeer: req.TargetPeer,
Ephemeral: req.Ephemeral,
}
return w.api.Post(ctx, msg)
}

View file

@ -16,6 +16,7 @@ type NewMessage struct {
PowTime uint32 `json:"powTime"`
PowTarget float64 `json:"powTarget"`
TargetPeer string `json:"targetPeer"`
Ephemeral bool `json:"ephemeral"`
}
// Message is the RPC representation of a whisper message.

View file

@ -551,6 +551,8 @@ func (s *MessageSender) SendPublic(
}
}
newMessage.Ephemeral = rawMessage.Ephemeral
messageID := v1protocol.MessageID(&rawMessage.Sender.PublicKey, wrappedMessage)
rawMessage.ID = types.EncodeHex(messageID)

View file

@ -33,4 +33,5 @@ type RawMessage struct {
SendOnPersonalTopic bool
CommunityID []byte
CommunityKeyExMsgType CommKeyExMsgType
Ephemeral bool
}

View file

@ -68,6 +68,7 @@ func (m *Messenger) sendUserStatus(ctx context.Context, status UserStatus) error
Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_STATUS_UPDATE,
ResendAutomatically: true,
Ephemeral: statusUpdate.StatusType == protobuf.StatusUpdate_AUTOMATIC,
}
_, err = m.sender.SendPublic(ctx, contactCodeTopic, rawMessage)
@ -168,6 +169,7 @@ func (m *Messenger) sendCurrentUserStatusToCommunity(ctx context.Context, commun
Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_STATUS_UPDATE,
ResendAutomatically: true,
Ephemeral: statusUpdate.StatusType == protobuf.StatusUpdate_AUTOMATIC,
}
_, err = m.sender.SendPublic(ctx, rawMessage.LocalChatID, rawMessage)

View file

@ -222,6 +222,7 @@ type NewMessage struct {
PowTime uint32 `json:"powTime"`
PowTarget float64 `json:"powTarget"`
TargetPeer string `json:"targetPeer"`
Ephemeral bool `json:"ephemeral"`
}
// Post posts a message on the Waku network.

View file

@ -179,6 +179,7 @@ type NewMessage struct {
Payload []byte `json:"payload"`
Padding []byte `json:"padding"`
TargetPeer string `json:"targetPeer"`
Ephemeral bool `json:"ephemeral"`
}
// Post posts a message on the Waku network.
@ -253,6 +254,7 @@ func (api *PublicWakuAPI) Post(ctx context.Context, req NewMessage) (hexutil.Byt
Version: version,
ContentTopic: req.Topic.ContentTopic(),
Timestamp: utils.GetUnixEpoch(),
Ephemeral: req.Ephemeral,
}
hash, err := api.w.Send(wakuMsg)