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,
Newline: "\n",
PillConverter: func(mxid, eventID string, ctx format.Context) string {
PillConverter: func(displayname, mxid, eventID string, ctx format.Context) string {
if mxid[0] == '@' {
puppet := bridge.GetPuppetByMXID(id.UserID(mxid))
if puppet != nil {
jids, ok := ctx[mentionedJIDsContextKey].([]types.GroupMeID)
jids, ok := ctx[mentionedJIDsContextKey].([]whatsapp.JID)
if !ok {
ctx[mentionedJIDsContextKey] = []types.GroupMeID{puppet.JID}
ctx[mentionedJIDsContextKey] = []whatsapp.JID{puppet.JID}
} else {
ctx[mentionedJIDsContextKey] = append(jids, puppet.JID)
}
@ -97,7 +97,8 @@ func NewFormatter(bridge *Bridge) *Formatter {
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
}

View File

@ -1984,7 +1984,7 @@ func (portal *Portal) convertGifToVideo(gif []byte) ([]byte, error) {
"-pix_fmt", "yuv420p", "-c:v", "libx264", "-movflags", "+faststart",
"-filter:v", "crop='floor(in_w/2)*2:floor(in_h/2)*2'",
outputFileName)
vcLog := portal.log.Sub("VideoConverter").WithDefaultLevel(log.LevelWarn)
vcLog := portal.log.Sub("VideoConverter").Writer(log.LevelWarn)
cmd.Stdout = 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
if user.bridge.Config.Homeserver.Asmux {
urlPath := intent.BuildBaseURL("_matrix", "client", "unstable", "net.maunium.asmux", "dms")
_, err = intent.MakeFullRequest(method, urlPath, http.Header{
"X-Asmux-Auth": {user.bridge.AS.Registration.AppToken},
}, chats, nil)
// _, err = intent.MakeFullRequest(method, urlPath, http.Header{
// "X-Asmux-Auth": {user.bridge.AS.Registration.AppToken},
// }, 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 {
existingChats := make(map[id.UserID][]id.RoomID)
err = intent.GetAccountData(event.AccountDataDirectChats.Type, &existingChats)