make it match whatsapp

This commit is contained in:
Annie Elequin 2021-09-16 18:24:59 -04:00
parent 2b50e1b798
commit 43109ec919
3 changed files with 15 additions and 8 deletions

View File

@ -51,13 +51,13 @@ func NewFormatter(bridge *Bridge) *Formatter {
TabsToSpaces: 4, TabsToSpaces: 4,
Newline: "\n", Newline: "\n",
PillConverter: func(mxid, eventID string, ctx format.Context) string { PillConverter: func(displayname, mxid, eventID string, ctx format.Context) string {
if mxid[0] == '@' { if mxid[0] == '@' {
puppet := bridge.GetPuppetByMXID(id.UserID(mxid)) puppet := bridge.GetPuppetByMXID(id.UserID(mxid))
if puppet != nil { if puppet != nil {
jids, ok := ctx[mentionedJIDsContextKey].([]types.GroupMeID) jids, ok := ctx[mentionedJIDsContextKey].([]whatsapp.JID)
if !ok { if !ok {
ctx[mentionedJIDsContextKey] = []types.GroupMeID{puppet.JID} ctx[mentionedJIDsContextKey] = []whatsapp.JID{puppet.JID}
} else { } else {
ctx[mentionedJIDsContextKey] = append(jids, puppet.JID) ctx[mentionedJIDsContextKey] = append(jids, puppet.JID)
} }
@ -97,7 +97,8 @@ func NewFormatter(bridge *Bridge) *Formatter {
return fmt.Sprintf("<code>%s</code>", str) return fmt.Sprintf("<code>%s</code>", str)
}, },
} }
formatter.waReplFuncText = map[*regexp.Regexp]func(string) string{} formatter.waReplFuncText = map[*regexp.Regexp]func(string) string{
}
return formatter return formatter
} }

View File

@ -1984,7 +1984,7 @@ func (portal *Portal) convertGifToVideo(gif []byte) ([]byte, error) {
"-pix_fmt", "yuv420p", "-c:v", "libx264", "-movflags", "+faststart", "-pix_fmt", "yuv420p", "-c:v", "libx264", "-movflags", "+faststart",
"-filter:v", "crop='floor(in_w/2)*2:floor(in_h/2)*2'", "-filter:v", "crop='floor(in_w/2)*2:floor(in_h/2)*2'",
outputFileName) outputFileName)
vcLog := portal.log.Sub("VideoConverter").WithDefaultLevel(log.LevelWarn) vcLog := portal.log.Sub("VideoConverter").Writer(log.LevelWarn)
cmd.Stdout = vcLog cmd.Stdout = vcLog
cmd.Stderr = vcLog cmd.Stderr = vcLog

12
user.go
View File

@ -695,9 +695,15 @@ func (user *User) UpdateDirectChats(chats map[id.UserID][]id.RoomID) {
var err error var err error
if user.bridge.Config.Homeserver.Asmux { if user.bridge.Config.Homeserver.Asmux {
urlPath := intent.BuildBaseURL("_matrix", "client", "unstable", "net.maunium.asmux", "dms") urlPath := intent.BuildBaseURL("_matrix", "client", "unstable", "net.maunium.asmux", "dms")
_, err = intent.MakeFullRequest(method, urlPath, http.Header{ // _, err = intent.MakeFullRequest(method, urlPath, http.Header{
"X-Asmux-Auth": {user.bridge.AS.Registration.AppToken}, // "X-Asmux-Auth": {user.bridge.AS.Registration.AppToken},
}, chats, nil) // }, chats, nil)
_, err = intent.MakeFullRequest(mautrix.FullRequest{
Method: method,
URL: urlPath,
Headers: http.Header{"X-Asmux-Auth": {user.bridge.AS.Registration.AppToken}},
RequestJSON: chats,
})
} else { } else {
existingChats := make(map[id.UserID][]id.RoomID) existingChats := make(map[id.UserID][]id.RoomID)
err = intent.GetAccountData(event.AccountDataDirectChats.Type, &existingChats) err = intent.GetAccountData(event.AccountDataDirectChats.Type, &existingChats)