feat_: Send payment request data
This commit is contained in:
parent
b329b158c8
commit
c12b48157a
|
@ -283,6 +283,7 @@ func (m *Message) MarshalJSON() ([]byte, error) {
|
||||||
ContactVerificationState ContactVerificationState `json:"contactVerificationState,omitempty"`
|
ContactVerificationState ContactVerificationState `json:"contactVerificationState,omitempty"`
|
||||||
DiscordMessage *protobuf.DiscordMessage `json:"discordMessage,omitempty"`
|
DiscordMessage *protobuf.DiscordMessage `json:"discordMessage,omitempty"`
|
||||||
BridgeMessage *protobuf.BridgeMessage `json:"bridgeMessage,omitempty"`
|
BridgeMessage *protobuf.BridgeMessage `json:"bridgeMessage,omitempty"`
|
||||||
|
PaymentRequests []*protobuf.PaymentRequest `json:"paymentRequests,omitempty"`
|
||||||
}
|
}
|
||||||
item := MessageStructType{
|
item := MessageStructType{
|
||||||
ID: m.ID,
|
ID: m.ID,
|
||||||
|
@ -325,6 +326,7 @@ func (m *Message) MarshalJSON() ([]byte, error) {
|
||||||
DeletedForMe: m.DeletedForMe,
|
DeletedForMe: m.DeletedForMe,
|
||||||
ContactRequestState: m.ContactRequestState,
|
ContactRequestState: m.ContactRequestState,
|
||||||
ContactVerificationState: m.ContactVerificationState,
|
ContactVerificationState: m.ContactVerificationState,
|
||||||
|
PaymentRequests: m.PaymentRequests,
|
||||||
}
|
}
|
||||||
|
|
||||||
if sticker := m.GetSticker(); sticker != nil {
|
if sticker := m.GetSticker(); sticker != nil {
|
||||||
|
|
|
@ -115,7 +115,8 @@ func (db sqlitePersistence) tableUserMessagesAllFields() string {
|
||||||
contact_verification_status,
|
contact_verification_status,
|
||||||
mentioned,
|
mentioned,
|
||||||
replied,
|
replied,
|
||||||
discord_message_id`
|
discord_message_id,
|
||||||
|
payment_requests`
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep the same order as in tableUserMessagesScanAllFields
|
// keep the same order as in tableUserMessagesScanAllFields
|
||||||
|
@ -148,6 +149,7 @@ func (db sqlitePersistence) tableUserMessagesAllFieldsJoin() string {
|
||||||
m1.links,
|
m1.links,
|
||||||
m1.unfurled_links,
|
m1.unfurled_links,
|
||||||
m1.unfurled_status_links,
|
m1.unfurled_status_links,
|
||||||
|
m1.payment_requests,
|
||||||
m1.command_id,
|
m1.command_id,
|
||||||
m1.command_value,
|
m1.command_value,
|
||||||
m1.command_from,
|
m1.command_from,
|
||||||
|
@ -243,6 +245,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
|
||||||
var serializedLinks []byte
|
var serializedLinks []byte
|
||||||
var serializedUnfurledLinks []byte
|
var serializedUnfurledLinks []byte
|
||||||
var serializedUnfurledStatusLinks []byte
|
var serializedUnfurledStatusLinks []byte
|
||||||
|
var serializedPaymentRequests []byte
|
||||||
var alias sql.NullString
|
var alias sql.NullString
|
||||||
var identicon sql.NullString
|
var identicon sql.NullString
|
||||||
var communityID sql.NullString
|
var communityID sql.NullString
|
||||||
|
@ -303,6 +306,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
|
||||||
&serializedLinks,
|
&serializedLinks,
|
||||||
&serializedUnfurledLinks,
|
&serializedUnfurledLinks,
|
||||||
&serializedUnfurledStatusLinks,
|
&serializedUnfurledStatusLinks,
|
||||||
|
&serializedPaymentRequests,
|
||||||
&command.ID,
|
&command.ID,
|
||||||
&command.Value,
|
&command.Value,
|
||||||
&command.From,
|
&command.From,
|
||||||
|
@ -474,6 +478,13 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
|
||||||
message.UnfurledStatusLinks = &links
|
message.UnfurledStatusLinks = &links
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if serializedPaymentRequests != nil {
|
||||||
|
err := json.Unmarshal(serializedPaymentRequests, &message.PaymentRequests)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if attachment.Id != "" {
|
if attachment.Id != "" {
|
||||||
discordMessage.Attachments = append(discordMessage.Attachments, attachment)
|
discordMessage.Attachments = append(discordMessage.Attachments, attachment)
|
||||||
}
|
}
|
||||||
|
@ -581,6 +592,14 @@ func (db sqlitePersistence) tableUserMessagesAllValues(message *common.Message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var serializedPaymentRequests []byte
|
||||||
|
if len(message.PaymentRequests) != 0 {
|
||||||
|
serializedPaymentRequests, err = json.Marshal(message.PaymentRequests)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
message.ID,
|
message.ID,
|
||||||
message.WhisperTimestamp,
|
message.WhisperTimestamp,
|
||||||
|
@ -638,6 +657,7 @@ func (db sqlitePersistence) tableUserMessagesAllValues(message *common.Message)
|
||||||
message.Mentioned,
|
message.Mentioned,
|
||||||
message.Replied,
|
message.Replied,
|
||||||
discordMessage.Id,
|
discordMessage.Id,
|
||||||
|
serializedPaymentRequests,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE user_messages ADD COLUMN payment_requests BLOB;
|
|
@ -119,6 +119,13 @@ message BridgeMessage {
|
||||||
string parentMessageID = 7;
|
string parentMessageID = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message PaymentRequest {
|
||||||
|
string receiver = 1;
|
||||||
|
string symbol = 2;
|
||||||
|
string amount = 3;
|
||||||
|
uint32 chainId = 4;
|
||||||
|
}
|
||||||
|
|
||||||
message UnfurledLinkThumbnail {
|
message UnfurledLinkThumbnail {
|
||||||
bytes payload = 1;
|
bytes payload = 1;
|
||||||
uint32 width = 2;
|
uint32 width = 2;
|
||||||
|
@ -234,6 +241,8 @@ message ChatMessage {
|
||||||
|
|
||||||
uint32 customization_color = 19;
|
uint32 customization_color = 19;
|
||||||
|
|
||||||
|
repeated PaymentRequest payment_requests = 20;
|
||||||
|
|
||||||
enum ContentType {
|
enum ContentType {
|
||||||
UNKNOWN_CONTENT_TYPE = 0;
|
UNKNOWN_CONTENT_TYPE = 0;
|
||||||
TEXT_PLAIN = 1;
|
TEXT_PLAIN = 1;
|
||||||
|
|
Loading…
Reference in New Issue