add "server_name" to config.yaml
This commit is contained in:
parent
f73a475132
commit
5211e5a615
|
@ -29,6 +29,7 @@ type Config struct {
|
||||||
Homeserver struct {
|
Homeserver struct {
|
||||||
Address string `yaml:"address"`
|
Address string `yaml:"address"`
|
||||||
Domain string `yaml:"domain"`
|
Domain string `yaml:"domain"`
|
||||||
|
ServerName string `yaml:"server_name"`
|
||||||
} `yaml:"homeserver"`
|
} `yaml:"homeserver"`
|
||||||
|
|
||||||
AppService struct {
|
AppService struct {
|
||||||
|
|
|
@ -4,6 +4,8 @@ homeserver:
|
||||||
address: https://example.com
|
address: https://example.com
|
||||||
# The domain of the homeserver (for MXIDs, etc).
|
# The domain of the homeserver (for MXIDs, etc).
|
||||||
domain: example.com
|
domain: example.com
|
||||||
|
# If you don’t know what this is, no need to modify(for parse "mention user/reply message, etc")
|
||||||
|
server_name: matrix.to
|
||||||
|
|
||||||
# Application service host/registration related details.
|
# Application service host/registration related details.
|
||||||
# Changing these values requires regeneration of the registration.
|
# Changing these values requires regeneration of the registration.
|
||||||
|
|
|
@ -138,8 +138,8 @@ func (formatter *Formatter) ParseSkype(content *event.MessageEventContent, RoomM
|
||||||
msgMXID = string(msg.MXID)
|
msgMXID = string(msg.MXID)
|
||||||
}
|
}
|
||||||
mxid, _ = formatter.getMatrixInfoByJID("8:" + match[1] + skypeExt.NewUserSuffix)
|
mxid, _ = formatter.getMatrixInfoByJID("8:" + match[1] + skypeExt.NewUserSuffix)
|
||||||
href1 := fmt.Sprintf(`https://%s/#/room/%s/%s?via=%s`, formatter.bridge.Config.Homeserver.Domain, RoomMXID, msgMXID, formatter.bridge.Config.Homeserver.Domain)
|
href1 := fmt.Sprintf(`https://%s/#/room/%s/%s?via=%s`, formatter.bridge.Config.Homeserver.ServerName, RoomMXID, msgMXID, formatter.bridge.Config.Homeserver.Domain)
|
||||||
href2 := fmt.Sprintf(`https://%s/#/user/%s`, formatter.bridge.Config.Homeserver.Domain, mxid)
|
href2 := fmt.Sprintf(`https://%s/#/user/%s`, formatter.bridge.Config.Homeserver.ServerName, mxid)
|
||||||
newContent := fmt.Sprintf(`<mx-reply><blockquote><a href="%s">In reply to</a> <a href="%s">%s</a><br>%s</blockquote></mx-reply>`,
|
newContent := fmt.Sprintf(`<mx-reply><blockquote><a href="%s">In reply to</a> <a href="%s">%s</a><br>%s</blockquote></mx-reply>`,
|
||||||
href1,
|
href1,
|
||||||
href2,
|
href2,
|
||||||
|
@ -170,9 +170,10 @@ func (formatter *Formatter) ParseSkype(content *event.MessageEventContent, RoomM
|
||||||
if len(matches) > 0 {
|
if len(matches) > 0 {
|
||||||
for _, match := range matches {
|
for _, match := range matches {
|
||||||
mxid, displayname := formatter.getMatrixInfoByJID(match[1] + skypeExt.NewUserSuffix)
|
mxid, displayname := formatter.getMatrixInfoByJID(match[1] + skypeExt.NewUserSuffix)
|
||||||
number := "@" + strings.Replace(match[1], skypeExt.NewUserSuffix, "", 1)
|
// number := "@" + strings.Replace(match[1], skypeExt.NewUserSuffix, "", 1)
|
||||||
originStr = strings.ReplaceAll(originStr, match[0], fmt.Sprintf(`<a href="https://%s/#/%s">%s</a>:`, formatter.bridge.Config.Homeserver.Domain, mxid, displayname))
|
replaceStr := fmt.Sprintf(`<a href="https://%s/#/%s">%s</a>:`, formatter.bridge.Config.Homeserver.ServerName, mxid, displayname)
|
||||||
originBodyStr = strings.Replace(originStr, number, displayname, -1)
|
originStr = strings.ReplaceAll(originStr, match[0], replaceStr)
|
||||||
|
originBodyStr = strings.ReplaceAll(originStr, replaceStr, displayname + ":")
|
||||||
}
|
}
|
||||||
if len(backStr) == 0 {
|
if len(backStr) == 0 {
|
||||||
content.Format = event.FormatHTML
|
content.Format = event.FormatHTML
|
||||||
|
|
|
@ -2042,7 +2042,7 @@ func (portal *Portal) convertMatrixMessageSkype(sender *User, evt *event.Event)
|
||||||
}
|
}
|
||||||
|
|
||||||
// mention user message
|
// mention user message
|
||||||
r := regexp.MustCompile(`(?m)<a[^>]+\bhref="(.*?)://` + portal.bridge.Config.Homeserver.Domain + `/#/@([^"]+):(.*?)">(.*?)</a>`)
|
r := regexp.MustCompile(`(?m)<a[^>]+\bhref="(.*?)://` + portal.bridge.Config.Homeserver.ServerName + `/#/@([^"]+):(.*?)">(.*?)</a>`)
|
||||||
matches := r.FindAllStringSubmatch(matchStr, -1)
|
matches := r.FindAllStringSubmatch(matchStr, -1)
|
||||||
fmt.Println("matches: ", matches)
|
fmt.Println("matches: ", matches)
|
||||||
if len(matches) > 0 {
|
if len(matches) > 0 {
|
||||||
|
|
Loading…
Reference in New Issue