Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
997bbc85c2 | ||
|
|
b140fdb390 | ||
|
|
c9511a636e | ||
|
|
ca673bd1d4 | ||
|
|
4ddea7cd3d |
No files matched your search
@@ -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!"
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -47,12 +47,25 @@ 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
|
||||
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 }}"
|
||||
docker pull "$SRC"
|
||||
retry docker pull "$SRC"
|
||||
docker tag "$SRC" "$IMAGE:latest"
|
||||
docker push "$IMAGE:latest"
|
||||
retry docker push "$IMAGE:latest"
|
||||
echo "Publicado: $IMAGE:latest (mesmo digest de $SRC)"
|
||||
@@ -26,6 +26,14 @@
|
||||
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
|
||||
@@ -53,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
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -546,6 +546,15 @@ func (s *sendService) validateAndCheckUserExists(phone string, formatJid *bool,
|
||||
|
||||
// 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.)
|
||||
@@ -602,6 +611,32 @@ 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.
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
@@ -230,6 +230,28 @@ func BRPhoneVariants(number string) []string {
|
||||
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 == "" {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user