diff --git a/formatting.go b/formatting.go
index f87d147..654fe68 100644
--- a/formatting.go
+++ b/formatting.go
@@ -81,7 +81,8 @@ func NewFormatter(bridge *Bridge) *Formatter {
},
mentionRegex: func(str string) string {
mxid, displayname := formatter.getMatrixInfoByJID(str[1:] + skypeExt.NewUserSuffix)
- return fmt.Sprintf(`%s`, mxid, displayname)
+ mxid = id.UserID(html.EscapeString(string(mxid)))
+ return fmt.Sprintf(`%s:`, bridge.Config.Homeserver.Domain, mxid, displayname)
},
}
formatter.waReplFuncText = map[*regexp.Regexp]func(string) string{
@@ -96,7 +97,8 @@ func NewFormatter(bridge *Bridge) *Formatter {
}
}
//mxid, displayname := formatter.getMatrixInfoByJID(str[1:] + whatsappExt.NewUserSuffix)
- return fmt.Sprintf(`%s`, mxid, displayname)
+ mxid = id.UserID(html.EscapeString(string(mxid)))
+ return fmt.Sprintf(`%s:`, bridge.Config.Homeserver.Domain, mxid, displayname)
// _, displayname = formatter.getMatrixInfoByJID(str[1:] + whatsappExt.NewUserSuffix)
//fmt.Println("ParseWhatsAp4", displayname)
//return displayname
@@ -136,7 +138,7 @@ func (formatter *Formatter) ParseSkype(content *event.MessageEventContent) {
if len(matches) > 0 {
for _, match := range matches {
mxid, displayname = formatter.getMatrixInfoByJID(match[1] + skypeExt.NewUserSuffix)
- content.FormattedBody = strings.ReplaceAll(content.Body, match[0], fmt.Sprintf(`%s`, mxid, displayname))
+ content.FormattedBody = strings.ReplaceAll(content.Body, match[0], fmt.Sprintf(`%s:`, formatter.bridge.Config.Homeserver.Domain, mxid, displayname))
content.Body = content.FormattedBody
}
}
@@ -151,7 +153,7 @@ func (formatter *Formatter) ParseSkype(content *event.MessageEventContent) {
//href1 := fmt.Sprintf(`https://matrix.to/#/!kpouCkfhzvXgbIJmkP:oliver.matrix.host/$fHQNRydqqqAVS8usHRmXn0nIBM_FC-lo2wI2Uol7wu8?via=oliver.matrix.host`)
href1 := ""
//mxid `@skype&8-live-xxxxxx:name.matrix.server`
- href2 := fmt.Sprintf(`https://matrix.to/#/%s`, mxid)
+ href2 := fmt.Sprintf(`https://%s/#/%s`, formatter.bridge.Config.Homeserver.Domain, mxid)
newContent := fmt.Sprintf(` %s
%s
%s`,
href1,
href2,
diff --git a/portal.go b/portal.go
index 8fefab4..718ad5d 100644
--- a/portal.go
+++ b/portal.go
@@ -1895,7 +1895,7 @@ func (portal *Portal) convertMatrixMessageSkype(sender *User, evt *event.Event)
//replyToID := content.GetReplyTo()
var newContent string
//if len(replyToID) > 0 {
- rQuote := regexp.MustCompile(`]+\bhref="(.*?)://matrix\.to/#/@([^"]+):(.*?)">(.*?)
([^"]+)
(.*)`)
+ rQuote := regexp.MustCompile(`]+\bhref="(.*?)://` + portal.bridge.Config.Homeserver.Domain + `/#/@([^"]+):(.*?)">(.*?)
([^"]+)
(.*)`)
quoteMatches := rQuote.FindAllStringSubmatch(content.FormattedBody, -1)
fmt.Println("matches0: ", content.FormattedBody)
fmt.Println("matches1: ", quoteMatches)
@@ -1904,7 +1904,7 @@ func (portal *Portal) convertMatrixMessageSkype(sender *User, evt *event.Event)
if len(match) > 2 {
var skyId string
if strings.Index(match[4], "@skype") > -1 {
- skyId = strings.ReplaceAll(match[2], "skype&", "")
+ skyId = patch.ParseLocalPart(html.UnescapeString(match[2]), false)
skyId = strings.ReplaceAll(skyId, "skype&", "")
skyId = strings.ReplaceAll(skyId, "-", ":")
} else {
@@ -1970,13 +1970,16 @@ func (portal *Portal) convertMatrixMessageSkype(sender *User, evt *event.Event)
text = "/me " + text
}
if len(content.FormattedBody) > 0 {
- r := regexp.MustCompile(`]+\bhref="(.*?)://matrix\.to/#/@skype&([^"]+):(.*?)">(.*?)*`)
+ //r := regexp.MustCompile(`]+\bhref="(.*?)://` + portal.bridge.Config.Homeserver.Domain + `/#/@skype&([^"]+):(.*?)">(.*?)*`)
+ r := regexp.MustCompile(`]+\bhref="(.*?)://` + portal.bridge.Config.Homeserver.Domain + `/#/@([^"]+):(.*?)">(.*?)*`)
matches := r.FindAllStringSubmatch(content.FormattedBody, -1)
fmt.Println("matches: ", matches)
if len(matches) > 0 {
for _, match := range matches {
if len(match) > 2 {
- skyId := strings.ReplaceAll(match[2], "-", ":")
+ skyId := patch.ParseLocalPart(html.UnescapeString(match[2]), false)
+ skyId = strings.ReplaceAll(skyId, "skype&", "")
+ skyId = strings.ReplaceAll(skyId, "-", ":")
content.FormattedBody = strings.ReplaceAll(content.FormattedBody, match[0], fmt.Sprintf(`%s`, skyId, match[4]))
}
}