diff --git a/profiles/profile.go b/profiles/profile.go index 4f79773..ab80e2d 100644 --- a/profiles/profile.go +++ b/profiles/profile.go @@ -360,7 +360,7 @@ func GetProfileE164(tel string) (contacts.Contact, error) { } // GetProfileUUID get a profile by a phone number -func GetProfileUUID(uuid string) (*contacts.Contact, error) { +func GetProfileUUID(uuid string) (*Profile, error) { c := contacts.Contacts[uuid] profile := &Profile{} var err error @@ -440,5 +440,5 @@ func GetProfileUUID(uuid string) (*contacts.Contact, error) { } contacts.Contacts[c.UUID] = c contacts.WriteContactsToPath() - return &c, nil + return profile, nil } diff --git a/server.go b/server.go index ff1308c..81b516e 100644 --- a/server.go +++ b/server.go @@ -370,8 +370,18 @@ func GetProfile(uuid string, profileKey []byte) (*profiles.Profile, error) { } return profile, nil } +func GetProfileByUUID(uuid string) (*profiles.Profile, error) { + profile, err := profiles.GetProfileUUID(uuid) + if err != nil { + return nil, err + } + return profile, nil +} func GetProfileAndCredential(uuid string, profileKey []byte) (*profiles.Profile, error) { + if uuid == "" || len(profileKey) == 0 { + return nil, fmt.Errorf("uuid or profileKey is empty") + } profile, err := profiles.GetProfileAndCredential(uuid, profileKey) if err != nil { return nil, err