Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid uuid when recipient is in contact list #966

Merged
merged 5 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
run: |
curl -sLO https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x appimagetool-x86_64.AppImage
sudo apt-get update
sudo apt-get install -y fuse libfuse2

- name: Build AppImage (x86_64)
env:
Expand Down
19 changes: 18 additions & 1 deletion app/store/sessionV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package store
import (
"errors"
"fmt"
"regexp"

"github.com/nanu-c/axolotl/app/helpers"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -327,12 +328,28 @@ func (s *SessionV2) GetName() (string, error) {
}
return s.getDirectChatName()
}
func IsValidUUID(uuid string) bool {
r := regexp.MustCompile("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$")
return r.MatchString(uuid)
}

func (s *SessionV2) getDirectChatName() (string, error) {

recipient := RecipientsModel.GetRecipientById(s.DirectMessageRecipientID)
if recipient != nil {
if recipient.ProfileGivenName != "" {
return recipient.ProfileGivenName, nil
if !IsValidUUID(recipient.ProfileGivenName) {
return recipient.ProfileGivenName, nil
} else {
contact := GetContactForUUID(recipient.ProfileGivenName)
if contact != nil {
recipient.ProfileGivenName = contact.Name
go recipient.SaveRecipient()
return contact.Name, nil
} else {
return "Unknown", nil
}
}
}
return recipient.Username, nil
}
Expand Down
Loading