resolved conflicts
This commit is contained in:
parent
381c5f6116
commit
7d956bef94
|
@ -74,6 +74,7 @@ func (db sqlitePersistence) tableUserMessagesAllFieldsJoin() string {
|
|||
m1.parsed_text,
|
||||
m1.sticker_pack,
|
||||
m1.sticker_hash,
|
||||
m1.image_payload,
|
||||
COALESCE(m1.audio_duration_ms,0),
|
||||
m1.audio_base64,
|
||||
m1.community_id,
|
||||
|
@ -134,6 +135,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
|
|||
sticker := &protobuf.StickerMessage{}
|
||||
command := &common.CommandParameters{}
|
||||
audio := &protobuf.AudioMessage{}
|
||||
image := &protobuf.ImageMessage{}
|
||||
|
||||
args := []interface{}{
|
||||
&message.ID,
|
||||
|
@ -152,6 +154,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
|
|||
&message.ParsedText,
|
||||
&sticker.Pack,
|
||||
&sticker.Hash,
|
||||
&image.Payload,
|
||||
&audio.DurationMs,
|
||||
&message.Base64Audio,
|
||||
&communityID,
|
||||
|
@ -242,6 +245,9 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
|
|||
|
||||
case protobuf.ChatMessage_TRANSACTION_COMMAND:
|
||||
message.CommandParameters = command
|
||||
|
||||
case protobuf.ChatMessage_IMAGE:
|
||||
message.Payload = &protobuf.ChatMessage_Image{Image: image}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -575,3 +575,44 @@ func (m *Messenger) clearHistory(id string) (*MessengerResponse, error) {
|
|||
response.AddChat(chat)
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (m *Messenger) ShareImageMessage(request *requests.ShareImageMessage) (*MessengerResponse, error) {
|
||||
if err := request.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response := &MessengerResponse{}
|
||||
|
||||
msg, err := m.persistence.MessageByID(request.MessageID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var messages []*common.Message
|
||||
for _, pk := range request.Users {
|
||||
message := &common.Message{}
|
||||
message.ChatId = pk.String()
|
||||
message.Payload = msg.Payload
|
||||
message.ContentType = protobuf.ChatMessage_IMAGE
|
||||
messages = append(messages, message)
|
||||
|
||||
r, err := m.CreateOneToOneChat(&requests.CreateOneToOneChat{ID: pk})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := response.Merge(r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
sendMessagesResponse, err := m.SendChatMessages(context.Background(), messages)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := response.Merge(sendMessagesResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package requests
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
)
|
||||
|
||||
var ErrShareMessageInvalidID = errors.New("share image message: invalid id")
|
||||
var ErrShareMessageEmptyUsers = errors.New("share image message: empty users")
|
||||
|
||||
type ShareImageMessage struct {
|
||||
MessageID string `json:"id"`
|
||||
Users []types.HexBytes `json:"users"`
|
||||
}
|
||||
|
||||
func (s *ShareImageMessage) Validate() error {
|
||||
if len(s.MessageID) == 0 {
|
||||
return ErrShareMessageInvalidID
|
||||
}
|
||||
|
||||
if len(s.Users) == 0 {
|
||||
return ErrShareMessageEmptyUsers
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -411,6 +411,11 @@ func (api *PublicAPI) ShareCommunity(request *requests.ShareCommunity) (*protoco
|
|||
return api.service.messenger.ShareCommunity(request)
|
||||
}
|
||||
|
||||
// ShareImageMessage share the selected chat image with a set of users
|
||||
func (api *PublicAPI) ShareImageMessage(request *requests.ShareImageMessage) (*protocol.MessengerResponse, error) {
|
||||
return api.service.messenger.ShareImageMessage(request)
|
||||
}
|
||||
|
||||
// RemoveUserFromCommunity removes the user with pk from the community with ID
|
||||
func (api *PublicAPI) RemoveUserFromCommunity(communityID types.HexBytes, userPublicKey string) (*protocol.MessengerResponse, error) {
|
||||
return api.service.messenger.RemoveUserFromCommunity(communityID, userPublicKey)
|
||||
|
|
Loading…
Reference in New Issue