mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
parent
92cfc0095d
commit
b42ac0e83d
4 changed files with 6 additions and 7 deletions
|
|
@ -116,7 +116,7 @@ func (u *UserLogin) ensureHasMetadata(metaType MetaTypeCreator) *UserLogin {
|
|||
|
||||
func (u *UserLogin) sqlVariables() []any {
|
||||
var remoteProfile dbutil.JSON
|
||||
if !u.RemoteProfile.IsEmpty() {
|
||||
if !u.RemoteProfile.IsZero() {
|
||||
remoteProfile.Data = &u.RemoteProfile
|
||||
}
|
||||
return []any{u.BridgeID, u.UserMXID, u.ID, u.RemoteName, remoteProfile, dbutil.StrPtr(u.SpaceRoom), dbutil.JSON{Data: u.Metadata}}
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ func (prov *ProvisioningAPI) GetWhoami(w http.ResponseWriter, r *http.Request) {
|
|||
prevState.UserID = ""
|
||||
prevState.RemoteID = ""
|
||||
prevState.RemoteName = ""
|
||||
prevState.RemoteProfile = nil
|
||||
prevState.RemoteProfile = status.RemoteProfile{}
|
||||
resp.Logins[i] = RespWhoamiLogin{
|
||||
StateEvent: prevState.StateEvent,
|
||||
StateTS: prevState.Timestamp,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import (
|
|||
|
||||
"github.com/tidwall/sjson"
|
||||
"go.mau.fi/util/jsontime"
|
||||
"go.mau.fi/util/ptr"
|
||||
|
||||
"maunium.net/go/mautrix"
|
||||
"maunium.net/go/mautrix/bridgev2/networkid"
|
||||
|
|
@ -112,7 +111,7 @@ func (rp *RemoteProfile) Merge(other RemoteProfile) RemoteProfile {
|
|||
return other
|
||||
}
|
||||
|
||||
func (rp *RemoteProfile) IsEmpty() bool {
|
||||
func (rp *RemoteProfile) IsZero() bool {
|
||||
return rp == nil || (rp.Phone == "" && rp.Email == "" && rp.Username == "" && rp.Name == "" && rp.Avatar == "" && rp.AvatarFile == nil)
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +129,7 @@ type BridgeState struct {
|
|||
UserID id.UserID `json:"user_id,omitempty"`
|
||||
RemoteID networkid.UserLoginID `json:"remote_id,omitempty"`
|
||||
RemoteName string `json:"remote_name,omitempty"`
|
||||
RemoteProfile *RemoteProfile `json:"remote_profile,omitempty"`
|
||||
RemoteProfile RemoteProfile `json:"remote_profile,omitzero"`
|
||||
|
||||
Reason string `json:"reason,omitempty"`
|
||||
Info map[string]interface{} `json:"info,omitempty"`
|
||||
|
|
@ -210,7 +209,7 @@ func (pong *BridgeState) ShouldDeduplicate(newPong *BridgeState) bool {
|
|||
pong.StateEvent == newPong.StateEvent &&
|
||||
pong.RemoteName == newPong.RemoteName &&
|
||||
pong.UserAction == newPong.UserAction &&
|
||||
ptr.Val(pong.RemoteProfile) == ptr.Val(newPong.RemoteProfile) &&
|
||||
pong.RemoteProfile == newPong.RemoteProfile &&
|
||||
pong.Error == newPong.Error &&
|
||||
maps.EqualFunc(pong.Info, newPong.Info, reflect.DeepEqual) &&
|
||||
pong.Timestamp.Add(time.Duration(pong.TTL)*time.Second).After(time.Now())
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ func (ul *UserLogin) FillBridgeState(state status.BridgeState) status.BridgeStat
|
|||
state.UserID = ul.UserMXID
|
||||
state.RemoteID = ul.ID
|
||||
state.RemoteName = ul.RemoteName
|
||||
state.RemoteProfile = &ul.RemoteProfile
|
||||
state.RemoteProfile = ul.RemoteProfile
|
||||
filler, ok := ul.Client.(status.BridgeStateFiller)
|
||||
if ok {
|
||||
return filler.FillBridgeState(state)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue