Skip to content

melhorias - #169

Open
betoarts wants to merge 10 commits into
evolution-foundation:mainfrom
betoarts:main
Open

melhorias#169
betoarts wants to merge 10 commits into
evolution-foundation:mainfrom
betoarts:main

Conversation

@betoarts

@betoarts betoarts commented Aug 10, 2026

Copy link
Copy Markdown

Description

Related Issue

Closes #(issue_number)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement

Testing

  • Manual testing completed
  • Functionality verified in development environment
  • No breaking changes introduced

Screenshots (if applicable)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have tested my changes thoroughly
  • Any dependent changes have been merged and published

Additional Notes

Summary by Sourcery

Refine licensing runtime behavior, versioning, and deployment tooling while adding documentation and issue templates.

New Features:

  • Allow GLOBAL_API_KEY-based license bypass for non-blocking initialization when no stored license is present.
  • Expose license status and registration flows with clearer API responses and expanded gate middleware access for static assets.
  • Add Easypanel deployment assets including docker-compose schema and documentation for simplified cloud setup.
  • Introduce multilingual GitHub issue templates and a pull request template to standardize community contributions.

Bug Fixes:

  • Ensure license status endpoints return human-readable values like "active" instead of internal flags.
  • Improve link message sending by explicitly setting WhatsApp extended text preview type to video, fixing missing previews in some clients.

Enhancements:

  • Refactor runtime configuration keys and context fields to clearer, public names for instance, API key, tier, and customer ID.
  • Strengthen license server communication helpers and error handling while keeping HTTP client behavior consistent.
  • Update version handling so the binary reads from a VERSION file and Docker builds pass VERSION via build args for consistent tagging.
  • Adjust Dockerfile to robustly obtain the whatsmeow-lib dependency, including a fallback git clone when submodules are not available.
  • Extend heartbeat configuration with a named interval constant and ensure graceful deactivate calls on shutdown.
  • Refresh built manager assets references in index.html to point to the latest JS and CSS bundles.
  • Add trademark and branding policy documentation clarifying use of Evolution Foundation brand assets.

Build:

  • Modify the Docker publish workflow to fetch submodules, read VERSION, tag images with the VERSION and latest, and pass VERSION as a build arg.
  • Ensure Docker build context is explicitly set and VERSION is copied into the runtime image for introspection.

CI:

  • Add structured English and Portuguese bug report and feature request issue templates plus a standardized pull request template to GitHub configuration.

Deployment:

  • Add Easypanel-specific Docker assets, including docker-compose and schema files, to streamline container-based deployments.

Documentation:

  • Include a new TRADEMARKS policy and Easypanel deployment README to document branding rules and deployment options.

@sourcery-ai

sourcery-ai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refines licensing/runtime handling and observability, adds support for GLOBAL_API_KEY license bypass, improves endpoint gating and heartbeat/activation flows, introduces explicit config key constants and RuntimeData naming, wires versioning through VERSION file into binaries and Docker images (including Easypanel deployment support), and adjusts link preview messaging plus GitHub templates/trademark docs.

Sequence diagram for runtime initialization and GLOBAL_API_KEY license bypass

sequenceDiagram
    actor Admin
    participant main
    participant InitializeRuntime
    participant _8ftv
    participant _nk7y
    participant _2a2d
    participant ActivateIntegrity

    Admin->>main: start server (GLOBAL_API_KEY set)
    main->>InitializeRuntime: InitializeRuntime(tier, version, GLOBAL_API_KEY)
    InitializeRuntime->>_8ftv: load saved RuntimeData
    alt saved license found
        _8ftv-->>InitializeRuntime: RuntimeData(APIKey)
        InitializeRuntime->>ActivateIntegrity: ActivateIntegrity(rc)
        InitializeRuntime->>_2a2d: _2a2d(rc, version)
        _2a2d-->>InitializeRuntime: activation ok
    else no saved license and GLOBAL_API_KEY != ""
        _8ftv-->>InitializeRuntime: error / empty
        InitializeRuntime->>InitializeRuntime: set rc._jpwr = GLOBAL_API_KEY
        InitializeRuntime->>_nk7y: _nk7y(&RuntimeData{APIKey: GLOBAL_API_KEY, Tier: tier})
        _nk7y-->>InitializeRuntime: persist RuntimeData
        InitializeRuntime->>ActivateIntegrity: ActivateIntegrity(rc)
        InitializeRuntime->>_2a2d: _2a2d(rc, version) (async, errors ignored)
        _2a2d-->>InitializeRuntime: non-blocking
    else no license and no GLOBAL_API_KEY
        _8ftv-->>InitializeRuntime: error / empty
        InitializeRuntime->>InitializeRuntime: _p3() show registration required
    end
    InitializeRuntime-->>main: *RuntimeContext (IsActive reflects path taken)
Loading

File-Level Changes

Change Details Files
Refactor licensing/runtime context and HTTP client helpers, add GLOBAL_API_KEY bootstrapping path, and clean up configuration key handling.
  • Renamed many previously obfuscated helper functions and fields for HTTP/XOR/hex utilities, while preserving behavior for endpoint resolution, HMAC signing, and HTTP client usage.
  • Introduced public config key constants for instance ID, API key, tier, and customer ID, replacing magic strings in the runtime config persistence layer.
  • Renamed database handle and runtime configuration helpers (get/set/delete) and RuntimeData type for clarity while keeping GORM usage and error handling intact.
  • Updated runtime initialization to optionally accept GLOBAL_API_KEY from environment, bypassing external license validation while still persisting it and activating integrity asynchronously.
  • Extracted a helper to print the license-required banner, and simplified activation helper flow including code exchange, activation, heartbeat, and shutdown/deactivation requests.
  • Relaxed gate middleware to allow static asset extensions (svg, css, js, png, ico, woff2, woff, ttf) through regardless of license status.
  • Fixed license HTTP API responses to use human-readable strings ("active", "tier", "version") instead of internal flag names, and aligned activation response/status checks.
pkg/core/c0.go
Wire semantic version information from VERSION file into the Go binary and Docker images, and propagate it into CI and runtime.
  • Changed main.go default version from "dev" to "0.0.0" and added init logic to read VERSION file when ldflags did not override it.
  • Updated Dockerfile to copy VERSION into the final image and to ensure the whatsmeow-lib dependency is present by cloning it if the submodule was not fetched (for Easypanel).
  • Modified GitHub publish_docker_image workflow to check out submodules, read VERSION into an output, tag images with that version plus latest, and pass VERSION as a build-arg to Docker build.
  • Added Easypanel-specific docker-compose and README/schema to simplify deployment, wiring environment variables (GLOBAL_API_KEY, DB credentials) and volumes.
  • Updated built manager/dist index.html asset references to new JS/CSS filenames, consistent with a new build that likely embeds the updated versioned assets.
cmd/evolution-go/main.go
.github/workflows/publish_docker_image.yml
Dockerfile
docker/easypanel/docker-compose.yml
docker/easypanel/README.md
docker/easypanel/schema.json
manager/dist/index.html
Adjust link message sending to explicitly declare video preview type to the WhatsApp client.
  • In sendLinkWithRetry, set PreviewType on ExtendedTextMessage to VIDEO, using a local variable to avoid inline pointer to constant.
  • Kept existing link preview fields (Text, Title, MatchedText, JPEGThumbnail, Description) intact while hinting video content to clients.
pkg/sendMessage/service/send_service.go
Improve project governance and GitHub templates, and add trademark/notice documentation.
  • Added GitHub issue templates for bug reports and feature requests in both English and Portuguese, plus a project-wide pull request template.
  • Introduced TRADEMARKS.md and NOTICE files to document Evolution Foundation trademark and brand asset policy and legal notices.
  • Left LICENSE unchanged in diff view, indicating repository licensing is maintained while branding policy is clarified.
.github/ISSUE_TEMPLATE/-en--bug-report.yaml
.github/ISSUE_TEMPLATE/-pt--reportar-bug.yaml
.github/ISSUE_TEMPLATE/-en--feature-request.yaml
.github/ISSUE_TEMPLATE/-pt--solicitar-recurso.yaml
.github/pull_request_template.md
TRADEMARKS.md
NOTICE
LICENSE

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 3 issues, and left some high level feedback:

  • The introduction of GLOBAL_API_KEY as a license bypass path in InitializeRuntime significantly changes the security model; consider clearly separating this bypass into a configurable, explicitly documented mode with safeguards (e.g., environment flag or runtime warning level) so it cannot be enabled unintentionally in production.
  • The core licensing/runtime code still uses heavily obfuscated/private-style identifiers (_kc1, _b1h, _uw, _444, etc.), which makes maintenance and debugging harder; it would be beneficial to consistently rename these to meaningful, public-facing names now that several config keys have been clarified.
  • GateMiddleware now hardcodes a long list of static asset suffixes to bypass licensing; consider centralizing these patterns (e.g., in a configuration or helper) to avoid duplication and make future adjustments to static paths less error‑prone.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The introduction of GLOBAL_API_KEY as a license bypass path in InitializeRuntime significantly changes the security model; consider clearly separating this bypass into a configurable, explicitly documented mode with safeguards (e.g., environment flag or runtime warning level) so it cannot be enabled unintentionally in production.
- The core licensing/runtime code still uses heavily obfuscated/private-style identifiers (_kc1, _b1h, _uw, _444, etc.), which makes maintenance and debugging harder; it would be beneficial to consistently rename these to meaningful, public-facing names now that several config keys have been clarified.
- GateMiddleware now hardcodes a long list of static asset suffixes to bypass licensing; consider centralizing these patterns (e.g., in a configuration or helper) to avoid duplication and make future adjustments to static paths less error‑prone.

## Individual Comments

### Comment 1
<location path="pkg/core/c0.go" line_range="451-460" />
<code_context>
 				fmt.Printf("  ⚠ Remote activation notice failed (non-blocking): %v\n", err)
 			}
 		}()
+	} else if rc._444 != "" {
+		rc._jpwr = rc._444
+		// Bypass na validação externa para inicialização sem bloqueio de licença
+		go func() {
+			_2a2d(rc, _h7) // Apenas avisa assíncrono (ou ignora erro)
+		}()
+		_nk7y(&RuntimeData{APIKey: rc._444, Tier: _y6})
+		rc._uw = sha256.Sum256([]byte(rc._jpwr + rc._645))
+		rc._xk65.Store(true)
+		ActivateIntegrity(rc)
+		fmt.Printf("  ✓ GLOBAL_API_KEY accepted — LICENSE BYPASSED\n")
 	} else {
-		fmt.Println()
</code_context>
<issue_to_address>
**suggestion (bug_risk):** GLOBAL_API_KEY bypass path may skip remote activation failures silently, potentially hiding licensing issues.

In the `GLOBAL_API_KEY` branch (`rc._444`), `_2a2d(rc, _h7)` runs in a goroutine and its error is discarded. That keeps startup non-blocking but completely hides licensing-server issues while still marking the instance as active.

If this bypass is only for specific environments, consider at least logging `_2a2d` failures here (as in the normal activation path) or exposing a distinct `/license/status` state so operators can tell a bypassed license from a fully validated one.

```suggestion
		rc._jpwr = rc._444
		// Bypass na validação externa para inicialização sem bloqueio de licença,
		// mas ainda registra falhas de notificação remota para visibilidade operacional.
		go func() {
			if err := _2a2d(rc, _h7); err != nil {
				fmt.Printf("  ⚠ Remote activation notice failed under GLOBAL_API_KEY bypass (non-blocking): %v\n", err)
			}
		}()
		_nk7y(&RuntimeData{APIKey: rc._444, Tier: _y6})
		rc._uw = sha256.Sum256([]byte(rc._jpwr + rc._645))
		rc._xk65.Store(true)
		ActivateIntegrity(rc)
		fmt.Printf("  ✓ GLOBAL_API_KEY accepted — LICENSE BYPASSED\n")
```
</issue_to_address>

### Comment 2
<location path="Dockerfile" line_range="14-16" />
<code_context>
 COPY whatsmeow-lib/ ./whatsmeow-lib/

+# Fazer clone do submodule fallback se o Easypanel ignorar submodules
+RUN if [ ! -f "whatsmeow-lib/go.mod" ]; then \
+      rm -rf whatsmeow-lib && \
+      git clone https://github.com/EvolutionAPI/whatsmeow.git whatsmeow-lib; \
+    fi
+
</code_context>
<issue_to_address>
**issue (bug_risk):** The fallback `git clone` requires git to be present in the build image, which `golang:alpine` typically does not include.

This means the `RUN git clone ...` step will fail on the current base image when the submodule is missing. Please either install git in the build stage (e.g. `RUN apk add --no-cache git`) before this block, or switch to a base image that includes git so builds in minimal environments (including CI) continue to work.
</issue_to_address>

### Comment 3
<location path="docker/easypanel/README.md" line_range="18" />
<code_context>
+Se você conectou o Easypanel diretamente ao seu repositório GitHub e quer fazer deploy usando um arquivo Compose.
+
+1. Crie um novo projeto/serviço do tipo **App** no Easypanel.
+2. Em **Source**, selecione seu repositório no Github e marque a opção correspondente ao `Docker Compose`.
+3. Defina o caminho do arquivo docker compose como: `docker/easypanel/docker-compose.yml`.
+4. Defina as Environment Variables necessárias no Easypanel (como `GLOBAL_API_KEY`).
</code_context>
<issue_to_address>
**nitpick (typo):** Use the correct capitalization for "GitHub".

Please change "Github" to "GitHub" here to match the official branding and keep the docs consistent.

```suggestion
2. Em **Source**, selecione seu repositório no GitHub e marque a opção correspondente ao `Docker Compose`.
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread pkg/core/c0.go
Comment on lines +451 to +460
rc._jpwr = rc._444
// Bypass na validação externa para inicialização sem bloqueio de licença
go func() {
_2a2d(rc, _h7) // Apenas avisa assíncrono (ou ignora erro)
}()
_nk7y(&RuntimeData{APIKey: rc._444, Tier: _y6})
rc._uw = sha256.Sum256([]byte(rc._jpwr + rc._645))
rc._xk65.Store(true)
ActivateIntegrity(rc)
fmt.Printf(" ✓ GLOBAL_API_KEY accepted — LICENSE BYPASSED\n")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): GLOBAL_API_KEY bypass path may skip remote activation failures silently, potentially hiding licensing issues.

In the GLOBAL_API_KEY branch (rc._444), _2a2d(rc, _h7) runs in a goroutine and its error is discarded. That keeps startup non-blocking but completely hides licensing-server issues while still marking the instance as active.

If this bypass is only for specific environments, consider at least logging _2a2d failures here (as in the normal activation path) or exposing a distinct /license/status state so operators can tell a bypassed license from a fully validated one.

Suggested change
rc._jpwr = rc._444
// Bypass na validação externa para inicialização sem bloqueio de licença
go func() {
_2a2d(rc, _h7) // Apenas avisa assíncrono (ou ignora erro)
}()
_nk7y(&RuntimeData{APIKey: rc._444, Tier: _y6})
rc._uw = sha256.Sum256([]byte(rc._jpwr + rc._645))
rc._xk65.Store(true)
ActivateIntegrity(rc)
fmt.Printf(" ✓ GLOBAL_API_KEY accepted — LICENSE BYPASSED\n")
rc._jpwr = rc._444
// Bypass na validação externa para inicialização sem bloqueio de licença,
// mas ainda registra falhas de notificação remota para visibilidade operacional.
go func() {
if err := _2a2d(rc, _h7); err != nil {
fmt.Printf(" ⚠ Remote activation notice failed under GLOBAL_API_KEY bypass (non-blocking): %v\n", err)
}
}()
_nk7y(&RuntimeData{APIKey: rc._444, Tier: _y6})
rc._uw = sha256.Sum256([]byte(rc._jpwr + rc._645))
rc._xk65.Store(true)
ActivateIntegrity(rc)
fmt.Printf(" ✓ GLOBAL_API_KEY accepted — LICENSE BYPASSED\n")

Comment thread Dockerfile
Comment on lines +14 to +16
RUN if [ ! -f "whatsmeow-lib/go.mod" ]; then \
rm -rf whatsmeow-lib && \
git clone https://github.com/EvolutionAPI/whatsmeow.git whatsmeow-lib; \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): The fallback git clone requires git to be present in the build image, which golang:alpine typically does not include.

This means the RUN git clone ... step will fail on the current base image when the submodule is missing. Please either install git in the build stage (e.g. RUN apk add --no-cache git) before this block, or switch to a base image that includes git so builds in minimal environments (including CI) continue to work.

Se você conectou o Easypanel diretamente ao seu repositório GitHub e quer fazer deploy usando um arquivo Compose.

1. Crie um novo projeto/serviço do tipo **App** no Easypanel.
2. Em **Source**, selecione seu repositório no Github e marque a opção correspondente ao `Docker Compose`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (typo): Use the correct capitalization for "GitHub".

Please change "Github" to "GitHub" here to match the official branding and keep the docs consistent.

Suggested change
2. Em **Source**, selecione seu repositório no Github e marque a opção correspondente ao `Docker Compose`.
2. Em **Source**, selecione seu repositório no GitHub e marque a opção correspondente ao `Docker Compose`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant