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, PowTime: req.PowTime,
PowTarget: req.PowTarget, PowTarget: req.PowTarget,
TargetPeer: req.TargetPeer, TargetPeer: req.TargetPeer,
Ephemeral: req.Ephemeral,
} }
return w.api.Post(ctx, msg) 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, Payload: req.Payload,
Padding: req.Padding, Padding: req.Padding,
TargetPeer: req.TargetPeer, TargetPeer: req.TargetPeer,
Ephemeral: req.Ephemeral,
} }
return w.api.Post(ctx, msg) return w.api.Post(ctx, msg)
} }

View File

@ -16,6 +16,7 @@ type NewMessage struct {
PowTime uint32 `json:"powTime"` PowTime uint32 `json:"powTime"`
PowTarget float64 `json:"powTarget"` PowTarget float64 `json:"powTarget"`
TargetPeer string `json:"targetPeer"` TargetPeer string `json:"targetPeer"`
Ephemeral bool `json:"ephemeral"`
} }
// Message is the RPC representation of a whisper message. // 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) messageID := v1protocol.MessageID(&rawMessage.Sender.PublicKey, wrappedMessage)
rawMessage.ID = types.EncodeHex(messageID) rawMessage.ID = types.EncodeHex(messageID)

View File

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

View File

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

View File

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

View File

@ -179,6 +179,7 @@ type NewMessage struct {
Payload []byte `json:"payload"` Payload []byte `json:"payload"`
Padding []byte `json:"padding"` Padding []byte `json:"padding"`
TargetPeer string `json:"targetPeer"` TargetPeer string `json:"targetPeer"`
Ephemeral bool `json:"ephemeral"`
} }
// Post posts a message on the Waku network. // 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, Version: version,
ContentTopic: req.Topic.ContentTopic(), ContentTopic: req.Topic.ContentTopic(),
Timestamp: utils.GetUnixEpoch(), Timestamp: utils.GetUnixEpoch(),
Ephemeral: req.Ephemeral,
} }
hash, err := api.w.Send(wakuMsg) hash, err := api.w.Send(wakuMsg)