Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/connector/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
ContentContact ContentType = 13
ContentFile ContentType = 14
ContentLocation ContentType = 15
ContentFlex ContentType = 22
)

// ToType values for LINE message destinations.
Expand Down
4 changes: 3 additions & 1 deletion pkg/connector/handle_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (lc *LineClient) queueIncomingMessage(msg *line.Message, opType int) {
func isBridgeableContentType(msg *line.Message) bool {
switch ContentType(msg.ContentType) {
case ContentText, ContentImage, ContentVideo, ContentAudio,
ContentSticker, ContentContact, ContentFile, ContentLocation:
ContentSticker, ContentContact, ContentFile, ContentLocation, ContentFlex:
return true
default:
return msg.ContentMetadata["ORGCONTP"] == "CALL" || msg.ContentMetadata["ORGCONTP"] == "CONTACT"
Expand Down Expand Up @@ -290,6 +290,8 @@ func (lc *LineClient) convertLineMessage(ctx context.Context, portal *bridgev2.P
return h.ConvertLocation(data, replyRelatesTo)
case ContentContact:
return h.ConvertContact(data, replyRelatesTo)
case ContentFlex:
return h.ConvertFlex(data, replyRelatesTo)
}

// Handle device/phone contact shared via ORGCONTP (contentType 0 with vCard)
Expand Down
32 changes: 32 additions & 0 deletions pkg/connector/handlers/flex.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package handlers

import (
"strings"

"maunium.net/go/mautrix/bridgev2"
"maunium.net/go/mautrix/event"

"github.com/highesttt/matrix-line-messenger/pkg/line"
)

// ConvertFlex converts a LINE rich/Flex message to a Matrix fallback.
func (h *Handler) ConvertFlex(data line.Message, relatesTo *event.RelatesTo) (*bridgev2.ConvertedMessage, error) {
preview := strings.TrimSpace(data.ContentMetadata["ALT_TEXT"])
body := "LINE rich message. Check LINE for full details."
if preview != "" {
body += "\n\nPreview:\n" + preview
}

return &bridgev2.ConvertedMessage{
Parts: []*bridgev2.ConvertedMessagePart{
{
Type: event.EventMessage,
Content: &event.MessageEventContent{
MsgType: event.MsgNotice,
Body: body,
RelatesTo: relatesTo,
},
},
},
}, nil
}
Loading