Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b71495e93 | ||
|
|
03d619bb55 |
No files matched your search
@@ -0,0 +1,58 @@
|
|||||||
|
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 }}"
|
||||||
|
echo "$TOKEN" | docker login "$REGISTRY" -u "$USER" --password-stdin
|
||||||
|
|
||||||
|
- name: Re-etiquetar como latest
|
||||||
|
run: |
|
||||||
|
SRC="${{ steps.rel.outputs.source }}"
|
||||||
|
docker pull "$SRC"
|
||||||
|
docker tag "$SRC" "$IMAGE:latest"
|
||||||
|
docker push "$IMAGE:latest"
|
||||||
|
echo "Publicado: $IMAGE:latest (mesmo digest de $SRC)"
|
||||||
@@ -22,6 +22,11 @@
|
|||||||
(pacote inexistente); `ClientPayload_UserAgent_AppVersion` vem de
|
(pacote inexistente); `ClientPayload_UserAgent_AppVersion` vem de
|
||||||
`go.mau.fi/whatsmeow/proto/waWa6`.
|
`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).
|
||||||
|
|
||||||
### 🛡️ 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
|
||||||
`killChannel` agora são `safemap.Map` com RWMutex (upstream PR #196, issue #203).
|
`killChannel` agora são `safemap.Map` com RWMutex (upstream PR #196, issue #203).
|
||||||
|
|||||||
@@ -111,3 +111,18 @@ services:
|
|||||||
Como o pacote é privado, o host precisa de `docker login git.jf.eng.br`
|
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`.
|
(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>`.
|
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.
|
||||||
@@ -531,6 +531,16 @@ func (s *sendService) validateAndCheckUserExists(phone string, formatJid *bool,
|
|||||||
return types.NewJID("", types.DefaultUserServer), fmt.Errorf("failed to connect client: %v", err)
|
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
|
// Use CheckUser approach: formatJid=false by default
|
||||||
formatJidForCheck := false
|
formatJidForCheck := false
|
||||||
|
|
||||||
@@ -592,6 +602,40 @@ func (s *sendService) checkSingleUserExists(client *whatsmeow.Client, phone stri
|
|||||||
return remoteJID, true, nil
|
return remoteJID, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 {
|
func findURL(text string) string {
|
||||||
urlRegex := `http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+`
|
urlRegex := `http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+`
|
||||||
re := regexp.MustCompile(urlRegex)
|
re := regexp.MustCompile(urlRegex)
|
||||||
|
|||||||
@@ -187,6 +187,49 @@ func formatBRNumber(jid string) string {
|
|||||||
return jid
|
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
|
||||||
|
}
|
||||||
|
|
||||||
// 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 == "" {
|
||||||
|
|||||||
@@ -384,3 +384,34 @@ 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user