7 Commits
Author SHA1 Message Date
jfengandClaude Opus 5.5 997bbc85c2 merge: promote maintained-stable (v0.7.2-evogo.3) into main
Build Automatico / build (push) Successful in 27s
CI - Validacao Go / Validar Codigo e Testes (push) Successful in 4m26s
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 09:19:57 -03:00
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
jfengandClaude Opus 5.5 5b71495e93 fix(send): resolve Brazilian 9th digit by asking WhatsApp for both variants
CI - Validacao Go / Validar Codigo e Testes (push) Successful in 2m42s
Docker - Build e Publicacao / Build, Scan e Publicacao (push) Successful in 1m23s
Accounts created before the 9th digit rollout are still registered without it
(554291389691), newer ones with it (5542991389691). The DDD-based rewrite in
CreateJID cannot be right for every account, and the existence check queried
only the number as received, so sends to 5542991389691 failed for an account
registered as 554291389691.

validateAndCheckUserExists now queries both forms in one IsOnWhatsApp call and
uses the registered one (received form first). Non-Brazilian numbers, groups,
LIDs and landlines follow the previous path unchanged. Related: upstream
issue #214 / PR #208.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-10 21:11:49 -03:00
jfengandClaude Opus 5.5 03d619bb55 ci: promote last v* release in maintained-stable to :latest without rebuilding
CI - Validacao Go / Validar Codigo e Testes (push) Successful in 4m8s
Docker - Build e Publicacao / Build, Scan e Publicacao (push) Successful in 2m42s
Docker - Promover latest / Promover release para latest (push) Successful in 2m18s
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-09 13:40:58 -03:00
jfeng ca673bd1d4 docs(governance): update AGENTS.md with EvoGO maintenance guidelines
Build Automatico / build (push) Successful in 31s
2026-11-09 14:19:41 +00:00
jfeng 4ddea7cd3d Initial commit 2026-11-09 13:48:37 +00:00
10 changed files with 360 additions and 6 deletions

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
name: Build Automatico
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Baixar codigo
uses: actions/checkout@v4
- name: Verificar ambiente
run: |
echo "Gitea Actions funcionando!"
echo "Repositorio: ${{ github.repository }}"
echo "Branch: ${{ github.ref_name }}"
- name: Verificar projeto
run: |
if [ -f package.json ]; then
echo "Projeto Node.js detectado"
elif [ -f composer.json ]; then
echo "Projeto PHP detectado"
elif [ -f requirements.txt ]; then
echo "Projeto Python detectado"
elif [ -f Dockerfile ]; then
echo "Projeto Docker detectado"
else
echo "Projeto sem build configurado"
fi
- name: Finalizar
run: echo "Verificacao concluida!"
+17 -3
View File
@@ -97,20 +97,34 @@ jobs:
[ -n "$USER" ] || USER="${{ github.actor }}"
TOKEN="${{ secrets.REGISTRY_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
if: steps.meta.outputs.publish == 'true'
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 }}
for TAG in "${{ steps.meta.outputs.image_tag }}" "${{ steps.meta.outputs.version }}"; do
docker tag "$SRC" "$IMAGE:$TAG"
docker push "$IMAGE:$TAG"
push "$IMAGE:$TAG"
echo "Publicado: $IMAGE:$TAG"
done
if [ "${{ github.event.inputs.promote_latest }}" = "true" ]; then
docker tag "$SRC" "$IMAGE:latest"
docker push "$IMAGE:latest"
push "$IMAGE:latest"
echo "Publicado: $IMAGE:latest"
fi
+71
View File
@@ -0,0 +1,71 @@
name: Docker - Promover latest
# :latest = ultimo release v* contido em maintained-stable.
# Nao recompila: baixa a imagem imutavel <versao>-<sha7> ja publicada pelo
# docker-build.yml para aquela tag e apenas a re-etiqueta, preservando o digest.
# So roda quando maintained-stable avanca (promocao aprovada) ou manualmente.
on:
push:
branches:
- maintained-stable
workflow_dispatch:
concurrency:
group: promote-latest
cancel-in-progress: false
env:
REGISTRY: git.jf.eng.br
IMAGE: git.jf.eng.br/jfeng/evogo
jobs:
promote:
name: Promover release para latest
runs-on: ubuntu-latest
steps:
- name: Checkout do Repositorio
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Identificar release
id: rel
run: |
git fetch --tags --force
TAG=$(git describe --tags --abbrev=0 --match 'v*' HEAD)
SHA7=$(git rev-list -n1 "$TAG" | cut -c1-7)
VERSION="${TAG#v}"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "source=${IMAGE}:${VERSION}-${SHA7}" >> "$GITHUB_OUTPUT"
echo "Release: ${TAG} -> ${IMAGE}:${VERSION}-${SHA7}"
- name: Login no Gitea Package Registry
run: |
USER="${{ secrets.REGISTRY_USER }}"
[ -n "$USER" ] || USER="${{ github.actor }}"
TOKEN="${{ secrets.REGISTRY_TOKEN }}"
[ -n "$TOKEN" ] || TOKEN="${{ secrets.GITEA_TOKEN }}"
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
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 }}"
retry docker pull "$SRC"
docker tag "$SRC" "$IMAGE:latest"
retry docker push "$IMAGE:latest"
echo "Publicado: $IMAGE:latest (mesmo digest de $SRC)"
+15
View File
@@ -22,6 +22,19 @@
(pacote inexistente); `ClientPayload_UserAgent_AppVersion` vem de
`go.mau.fi/whatsmeow/proto/waWa6`.
- **Nono dígito (BR)** — envios para celulares brasileiros consultam no
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
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)
- **Crash `concurrent map writes`** — `clientPointer`, `myClientPointer` e
`killChannel` agora são `safemap.Map` com RWMutex (upstream PR #196, issue #203).
@@ -48,6 +61,8 @@
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
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
+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),
newsletter_handler.NewNewsletterHandler(newsletterService),
pollHandler,
server_handler.NewServerHandler(),
server_handler.NewServerHandler(version),
).AssignRoutes(r)
if config.ConnectOnStartup {
+15
View File
@@ -111,3 +111,18 @@ services:
Como o pacote é privado, o host precisa de `docker login git.jf.eng.br`
(usuário Gitea + token com escopo `read:package`) antes de `docker compose pull`.
Para fixar exatamente o commit testado, use a tag imutável `<versão>-<sha7>`.
### Promover para `:latest`
`.gitea/workflows/promote-latest.yml` roda quando `maintained-stable` avança:
re-etiqueta a imagem imutável do último release `v*` contido na branch
(`<versão>-<sha7>`) como `:latest`, sem recompilar (mesmo digest).
```bash
git checkout maintained-stable
git merge --ff-only v0.7.2-evogo.1
git push origin maintained-stable # dispara a promoção para :latest
```
Rollback de `:latest`: avance/reverta `maintained-stable` para o release
anterior e rode o workflow manualmente, ou fixe a tag de versão no compose.
+79
View File
@@ -531,11 +531,30 @@ func (s *sendService) validateAndCheckUserExists(phone string, formatJid *bool,
return types.NewJID("", types.DefaultUserServer), fmt.Errorf("failed to connect client: %v", err)
}
// Brazilian mobiles: ask WhatsApp for both forms (with and without the 9th
// digit) and use the one that is registered.
if variants := utils.BRPhoneVariants(phone); len(variants) > 1 {
if remoteJID, found := s.checkBRPhoneVariants(client, variants, instance.Id); found {
s.loggerWrapper.GetLogger(instance.Id).LogInfo("[%s] Number %s verified as valid WhatsApp user, using remoteJID: %s", instance.Id, phone, remoteJID)
formatJidFalse := false
return validateMessageFields(remoteJID, &formatJidFalse, messageID, participant)
}
}
// Use CheckUser approach: formatJid=false by default
formatJidForCheck := false
// First attempt with formatJid=false
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 {
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.)
@@ -592,6 +611,66 @@ func (s *sendService) checkSingleUserExists(client *whatsmeow.Client, phone stri
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
// 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.
func (s *sendService) checkBRPhoneVariants(client *whatsmeow.Client, variants []string, instanceId string) (string, bool) {
phones := make([]string, len(variants))
for i, v := range variants {
phones[i] = "+" + v
}
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
resp, err := client.IsOnWhatsApp(ctx, phones)
if err != nil {
s.loggerWrapper.GetLogger(instanceId).LogWarn("[%s] Failed to check BR number variants %v: %v", instanceId, variants, err)
return "", false
}
for _, v := range variants {
for _, r := range resp {
if r.IsIn && strings.TrimPrefix(r.Query, "+") == v {
return r.JID.String(), true
}
}
}
// Query not echoed back as sent: any registered result is one of our variants.
for _, r := range resp {
if r.IsIn {
return r.JID.String(), true
}
}
return "", false
}
func findURL(text string) string {
urlRegex := `http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+`
re := regexp.MustCompile(urlRegex)
+4 -2
View File
@@ -7,15 +7,17 @@ type ServerHandler interface {
}
type serverHandler struct {
version string
}
// ServerOk implements ServerHandler.
func (s *serverHandler) ServerOk(ctx *gin.Context) {
ctx.JSON(200, gin.H{
"status": "ok",
"version": s.version,
})
}
func NewServerHandler() ServerHandler {
return &serverHandler{}
func NewServerHandler(version string) ServerHandler {
return &serverHandler{version: version}
}
+65
View File
@@ -187,6 +187,71 @@ func formatBRNumber(jid string) string {
return jid
}
// BRPhoneVariants returns both forms of a Brazilian mobile number — with and
// without the 9th digit — with the received form first, or nil when the number
// is not a Brazilian mobile.
//
// Accounts created before the 9th digit rollout are still registered without
// it (e.g. 554291389691), newer ones with it (5542991389691). No fixed rule
// derived from the DDD is right for every account, so callers should ask
// WhatsApp which of the two exists.
func BRPhoneVariants(number string) []string {
if strings.Contains(number, "@") {
if !strings.HasSuffix(number, "@"+whatsmeow_types.DefaultUserServer) {
return nil
}
number = strings.Split(number, "@")[0]
}
number = strings.Split(number, ":")[0]
digits := strings.Map(func(r rune) rune {
if r >= '0' && r <= '9' {
return r
}
return -1
}, number)
// 55 + DDD (11-99, never starting with 0) + subscriber
if !strings.HasPrefix(digits, "55") || len(digits) < 12 || digits[2] == '0' {
return nil
}
switch len(digits) {
case 13:
if digits[4] == '9' {
return []string{digits, digits[:4] + digits[5:]}
}
case 12:
// 8-digit mobile numbers start with 6, 7, 8 or 9; landlines with 2-5
if digits[4] >= '6' {
return []string{digits, digits[:4] + "9" + digits[4:]}
}
}
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
func ParseJID(arg string) (whatsmeow_types.JID, bool) {
if arg == "" {
+51
View File
@@ -384,3 +384,54 @@ func TestCanonicalJID(t *testing.T) {
})
}
}
func TestBRPhoneVariants(t *testing.T) {
tests := []struct {
name string
input string
want []string
}{
{"13 digits with 9", "5542991389691", []string{"5542991389691", "554291389691"}},
{"12 digits without 9", "554291389691", []string{"554291389691", "5542991389691"}},
{"plus and JID suffix", "[email protected]", []string{"5511987654321", "551187654321"}},
{"formatted", "+55 (42) 99138-9691", []string{"5542991389691", "554291389691"}},
{"landline", "554232221234", nil},
{"not Brazil", "15551234567", nil},
{"group", "[email protected]", nil},
{"lid", "255284433936406@lid", nil},
{"13 digits without 9 after DDD", "5542891389691", nil},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := BRPhoneVariants(tt.input)
if len(got) != len(tt.want) {
t.Fatalf("BRPhoneVariants(%q) = %v, want %v", tt.input, got, tt.want)
}
for i := range got {
if got[i] != tt.want[i] {
t.Fatalf("BRPhoneVariants(%q) = %v, want %v", tt.input, got, tt.want)
}
}
})
}
}
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)
}
}
}