fix mention user bug
This commit is contained in:
parent
977b8996c7
commit
43b937d645
|
@ -159,14 +159,26 @@ func (formatter *Formatter) ParseSkype(content *event.MessageEventContent, RoomM
|
|||
|
||||
// parse mention user message
|
||||
r := regexp.MustCompile(`<at[^>]+\bid="([^"]+)"(.*?)</at>*`)
|
||||
matches := r.FindAllStringSubmatch(backStr, -1)
|
||||
var originStr string
|
||||
if len(backStr) == 0 {
|
||||
originStr = content.Body
|
||||
} else {
|
||||
originStr = backStr
|
||||
}
|
||||
matches := r.FindAllStringSubmatch(originStr, -1)
|
||||
if len(matches) > 0 {
|
||||
for _, match := range matches {
|
||||
mxid, displayname := formatter.getMatrixInfoByJID(match[1] + skypeExt.NewUserSuffix)
|
||||
number := "@" + strings.Replace(match[1], skypeExt.NewUserSuffix, "", 1)
|
||||
output = strings.ReplaceAll(backStr, match[0], fmt.Sprintf(`<a href="https://%s/#/%s">%s</a>:`, formatter.bridge.Config.Homeserver.Domain, mxid, displayname))
|
||||
content.FormattedBody = content.FormattedBody + output
|
||||
content.Body = content.Body + strings.Replace(backStr, number, displayname, -1)
|
||||
output = strings.ReplaceAll(originStr, match[0], fmt.Sprintf(`<a href="https://%s/#/%s">%s</a>:`, formatter.bridge.Config.Homeserver.Domain, mxid, displayname))
|
||||
if len(backStr) == 0 {
|
||||
content.Format = event.FormatHTML
|
||||
content.Body = strings.Replace(originStr, number, displayname, -1)
|
||||
content.FormattedBody = output
|
||||
} else {
|
||||
content.FormattedBody = content.FormattedBody + output
|
||||
content.Body = content.Body + strings.Replace(backStr, number, displayname, -1)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
content.Body = content.Body + backStr
|
||||
|
|
Loading…
Reference in New Issue