Author SHA1 Message Date
jfengandClaude Opus 5.5 b140fdb390 fix(send): send to known LIDs passed as phone numbers; expose version
Docker - Build e Publicacao / Build, Scan e Publicacao (push) Successful in 2m28s
CI - Validacao Go / Validar Codigo e Testes (push) Successful in 3m58s
Docker - Promover latest / Promover release para latest (push) Successful in 4m39s
Integrations that store the contact's LID as its number (255284433936406)
failed with 'no LID found for [email protected]'. When the number
is not a registered phone and the instance's LID store maps it to a phone
number, send to <number>@lid instead.

GET /server/ok now also returns the running version, so a deployment can be
checked without reading the startup log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 08:15:58 -03:00
jfengandClaude Opus 5.5 c9511a636e ci: retry registry login, pull and push
CI - Validacao Go / Validar Codigo e Testes (push) Successful in 1m48s
A transient timeout on the registry token endpoint failed the publication of
v0.7.2-evogo.2 (run 482) after the image had already been built and scanned.
Login, pull and push now retry up to 5 times with linear backoff.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 07:52:15 -03:00
8 changed files with 125 additions and 9 deletions

No files matched your search

+17 -3
View File
@@ -97,20 +97,34 @@ jobs:
[ -n "$USER" ] || USER="${{ github.actor }}" [ -n "$USER" ] || USER="${{ github.actor }}"
TOKEN="${{ secrets.REGISTRY_TOKEN }}" TOKEN="${{ secrets.REGISTRY_TOKEN }}"
[ -n "$TOKEN" ] || TOKEN="${{ secrets.GITEA_TOKEN }}" [ -n "$TOKEN" ] || TOKEN="${{ secrets.GITEA_TOKEN }}"
echo "$TOKEN" | docker login "$REGISTRY" -u "$USER" --password-stdin # O registry ja estourou timeout pontualmente (run 482); tenta de novo antes de falhar.
for n in 1 2 3 4 5; do
echo "$TOKEN" | docker login "$REGISTRY" -u "$USER" --password-stdin && exit 0
echo "Login falhou (tentativa $n/5); nova tentativa em $((n*15))s"
sleep $((n*15))
done
exit 1
- name: Publicar Imagens no Registry - name: Publicar Imagens no Registry
if: steps.meta.outputs.publish == 'true' if: steps.meta.outputs.publish == 'true'
run: | run: |
push() {
for n in 1 2 3 4 5; do
docker push "$1" && return 0
echo "Push de $1 falhou (tentativa $n/5); nova tentativa em $((n*15))s"
sleep $((n*15))
done
return 1
}
SRC=evogo:ci-${{ steps.meta.outputs.commit_sha }} SRC=evogo:ci-${{ steps.meta.outputs.commit_sha }}
for TAG in "${{ steps.meta.outputs.image_tag }}" "${{ steps.meta.outputs.version }}"; do for TAG in "${{ steps.meta.outputs.image_tag }}" "${{ steps.meta.outputs.version }}"; do
docker tag "$SRC" "$IMAGE:$TAG" docker tag "$SRC" "$IMAGE:$TAG"
docker push "$IMAGE:$TAG" push "$IMAGE:$TAG"
echo "Publicado: $IMAGE:$TAG" echo "Publicado: $IMAGE:$TAG"
done done
if [ "${{ github.event.inputs.promote_latest }}" = "true" ]; then if [ "${{ github.event.inputs.promote_latest }}" = "true" ]; then
docker tag "$SRC" "$IMAGE:latest" docker tag "$SRC" "$IMAGE:latest"
docker push "$IMAGE:latest" push "$IMAGE:latest"
echo "Publicado: $IMAGE:latest" echo "Publicado: $IMAGE:latest"
fi fi
+16 -3
View File
@@ -47,12 +47,25 @@ jobs:
[ -n "$USER" ] || USER="${{ github.actor }}" [ -n "$USER" ] || USER="${{ github.actor }}"
TOKEN="${{ secrets.REGISTRY_TOKEN }}" TOKEN="${{ secrets.REGISTRY_TOKEN }}"
[ -n "$TOKEN" ] || TOKEN="${{ secrets.GITEA_TOKEN }}" [ -n "$TOKEN" ] || TOKEN="${{ secrets.GITEA_TOKEN }}"
echo "$TOKEN" | docker login "$REGISTRY" -u "$USER" --password-stdin for n in 1 2 3 4 5; do
echo "$TOKEN" | docker login "$REGISTRY" -u "$USER" --password-stdin && exit 0
echo "Login falhou (tentativa $n/5); nova tentativa em $((n*15))s"
sleep $((n*15))
done
exit 1
- name: Re-etiquetar como latest - name: Re-etiquetar como latest
run: | run: |
retry() {
for n in 1 2 3 4 5; do
"$@" && return 0
echo "'$*' falhou (tentativa $n/5); nova tentativa em $((n*15))s"
sleep $((n*15))
done
return 1
}
SRC="${{ steps.rel.outputs.source }}" SRC="${{ steps.rel.outputs.source }}"
docker pull "$SRC" retry docker pull "$SRC"
docker tag "$SRC" "$IMAGE:latest" docker tag "$SRC" "$IMAGE:latest"
docker push "$IMAGE:latest" retry docker push "$IMAGE:latest"
echo "Publicado: $IMAGE:latest (mesmo digest de $SRC)" echo "Publicado: $IMAGE:latest (mesmo digest de $SRC)"
+10
View File
@@ -26,6 +26,14 @@
WhatsApp as duas variantes (com e sem o 9) e usam a que está registrada. WhatsApp as duas variantes (com e sem o 9) e usam a que está registrada.
Contas antigas sem o 9 (ex.: `554291389691`) passam a receber mesmo quando o Contas antigas sem o 9 (ex.: `554291389691`) passam a receber mesmo quando o
sistema envia `5542991389691`, e vice-versa (upstream issue #214 / PR #208). sistema envia `5542991389691`, e vice-versa (upstream issue #214 / PR #208).
- **LID enviado como número** — quando o `number` não existe como telefone mas
é o LID de um contato já conhecido pela instância (ex.: `255284433936406`),
o envio vai direto para `255284433936406@lid` em vez de falhar com
`no LID found for [email protected]`.
### 🆕 Novidades
- `GET /server/ok` passa a informar a versão em execução
(`{"status":"ok","version":"0.7.2-evogo.3-<sha7>"}`).
### 🛡️ Estabilidade (correções da comunidade incorporadas pelo EvoGO) ### 🛡️ Estabilidade (correções da comunidade incorporadas pelo EvoGO)
- **Crash `concurrent map writes`** — `clientPointer`, `myClientPointer` e - **Crash `concurrent map writes`** — `clientPointer`, `myClientPointer` e
@@ -53,6 +61,8 @@
e PR automático; conflitos viram Issue; aviso de whatsmeow desatualizado. e PR automático; conflitos viram Issue; aviso de whatsmeow desatualizado.
- Publicação da imagem em `git.jf.eng.br/jfeng/evogo` por tag `v*`, com tag - Publicação da imagem em `git.jf.eng.br/jfeng/evogo` por tag `v*`, com tag
imutável `<versão>-<sha7>` e scan Trivy. imutável `<versão>-<sha7>` e scan Trivy.
- Login, pull e push no registry com até 5 tentativas — um timeout pontual do
endpoint de token derrubou a publicação da `v0.7.2-evogo.2` (run 482).
## v0.7.2 ## v0.7.2
+1 -1
View File
@@ -239,7 +239,7 @@ func setupRouter(db *gorm.DB, authDB *sql.DB, sqliteDB *sql.DB, config *config.C
label_handler.NewLabelHandler(labelService), label_handler.NewLabelHandler(labelService),
newsletter_handler.NewNewsletterHandler(newsletterService), newsletter_handler.NewNewsletterHandler(newsletterService),
pollHandler, pollHandler,
server_handler.NewServerHandler(), server_handler.NewServerHandler(version),
).AssignRoutes(r) ).AssignRoutes(r)
if config.ConnectOnStartup { if config.ConnectOnStartup {
+35
View File
@@ -546,6 +546,15 @@ func (s *sendService) validateAndCheckUserExists(phone string, formatJid *bool,
// First attempt with formatJid=false // First attempt with formatJid=false
remoteJID, found, err := s.checkSingleUserExists(client, phone, formatJidForCheck, instance.Id) remoteJID, found, err := s.checkSingleUserExists(client, phone, formatJidForCheck, instance.Id)
if err != nil || !found {
// Integrations often store the contact's LID as if it were a phone
// number. If it is a LID this device already knows, send to it directly.
if lid, ok := s.knownLID(client, phone, instance.Id); ok {
s.loggerWrapper.GetLogger(instance.Id).LogInfo("[%s] Number %s is a known LID, sending to %s", instance.Id, phone, lid)
formatJidFalse := false
return validateMessageFields(lid.String(), &formatJidFalse, messageID, participant)
}
}
if err != nil { if err != nil {
s.loggerWrapper.GetLogger(instance.Id).LogWarn("[%s] Failed to check user existence: %v", instance.Id, err) s.loggerWrapper.GetLogger(instance.Id).LogWarn("[%s] Failed to check user existence: %v", instance.Id, err)
// Continue with sending even if check fails (network issues, etc.) // Continue with sending even if check fails (network issues, etc.)
@@ -602,6 +611,32 @@ func (s *sendService) checkSingleUserExists(client *whatsmeow.Client, phone stri
return remoteJID, true, nil return remoteJID, true, nil
} }
// knownLID reports whether phone is actually a LID with a phone number mapping
// in the local store, returning it as a @lid JID.
func (s *sendService) knownLID(client *whatsmeow.Client, phone string, instanceId string) (types.JID, bool) {
if client.Store == nil || client.Store.LIDs == nil {
return types.JID{}, false
}
user := utils.LIDCandidate(phone)
if user == "" {
return types.JID{}, false
}
lid := types.NewJID(user, types.HiddenUserServer)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
pn, err := client.Store.LIDs.GetPNForLID(ctx, lid)
if err != nil {
s.loggerWrapper.GetLogger(instanceId).LogWarn("[%s] Failed to look up LID %s: %v", instanceId, lid, err)
return types.JID{}, false
}
if pn.IsEmpty() {
return types.JID{}, false
}
return lid, true
}
// checkBRPhoneVariants queries every variant in a single IsOnWhatsApp call and // checkBRPhoneVariants queries every variant in a single IsOnWhatsApp call and
// returns the JID of the first one that is registered, in the given order. // returns the JID of the first one that is registered, in the given order.
// Errors are logged and reported as not found so the regular check still runs. // Errors are logged and reported as not found so the regular check still runs.
+4 -2
View File
@@ -7,15 +7,17 @@ type ServerHandler interface {
} }
type serverHandler struct { type serverHandler struct {
version string
} }
// ServerOk implements ServerHandler. // ServerOk implements ServerHandler.
func (s *serverHandler) ServerOk(ctx *gin.Context) { func (s *serverHandler) ServerOk(ctx *gin.Context) {
ctx.JSON(200, gin.H{ ctx.JSON(200, gin.H{
"status": "ok", "status": "ok",
"version": s.version,
}) })
} }
func NewServerHandler() ServerHandler { func NewServerHandler(version string) ServerHandler {
return &serverHandler{} return &serverHandler{version: version}
} }
+22
View File
@@ -230,6 +230,28 @@ func BRPhoneVariants(number string) []string {
return nil return nil
} }
// LIDCandidate returns the user part of number when it could be a LID sent as
// a phone number ("255284433936406", "[email protected]"), or ""
// when it has another server, a device suffix or non-digit characters.
func LIDCandidate(number string) string {
if strings.Contains(number, "@") {
if !strings.HasSuffix(number, "@"+whatsmeow_types.DefaultUserServer) {
return ""
}
number = strings.Split(number, "@")[0]
}
number = strings.TrimPrefix(strings.TrimSpace(number), "+")
if len(number) < 8 {
return ""
}
for _, r := range number {
if r < '0' || r > '9' {
return ""
}
}
return number
}
// ParseJID parses a number string into a WhatsApp JID with validation // ParseJID parses a number string into a WhatsApp JID with validation
func ParseJID(arg string) (whatsmeow_types.JID, bool) { func ParseJID(arg string) (whatsmeow_types.JID, bool) {
if arg == "" { if arg == "" {
+20
View File
@@ -415,3 +415,23 @@ func TestBRPhoneVariants(t *testing.T) {
}) })
} }
} }
func TestLIDCandidate(t *testing.T) {
tests := []struct {
input string
want string
}{
{"255284433936406", "255284433936406"},
{"[email protected]", "255284433936406"},
{"255284433936406@lid", ""},
{"[email protected]", ""},
{"255284433936406:[email protected]", ""},
{"+55 (42) 99138-9691", ""},
{"1234", ""},
}
for _, tt := range tests {
if got := LIDCandidate(tt.input); got != tt.want {
t.Errorf("LIDCandidate(%q) = %q, want %q", tt.input, got, tt.want)
}
}
}