Skip to content
Open
71 changes: 71 additions & 0 deletions .github/workflows/publish_ghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and Publish to GHCR

on:
push:
branches:
- main
- 'release/**'
tags:
- 'v*.*.*'
pull_request:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
name: Build and Publish
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v5
with:
submodules: recursive

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Image digest
if: github.event_name != 'pull_request'
run: echo ${{ steps.docker_build.outputs.digest }}
1 change: 1 addition & 0 deletions src/api/dto/business.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export class getCatalogDto {
export class getCollectionsDto {
number?: string;
limit?: number;
cursor?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4901,8 +4901,8 @@ export class BaileysStartupService extends ChannelStartupService {
//Business Controller
public async fetchCatalog(instanceName: string, data: getCollectionsDto) {
const jid = data.number ? createJid(data.number) : this.client?.user?.id;
const limit = data.limit || 10;
const cursor = null;
const limit = data.limit || 50;
const cursor = data.cursor || null;

const onWhatsapp = (await this.whatsappNumber({ numbers: [jid] }))?.shift();

Expand All @@ -4924,7 +4924,7 @@ export class BaileysStartupService extends ChannelStartupService {

let productsCatalog = catalog.products || [];
let countLoops = 0;
while (fetcherHasMore && countLoops < 4) {
while (fetcherHasMore && countLoops < 20) {
catalog = await this.getCatalog({ jid: info?.jid, limit, cursor: nextPageCursor });
nextPageCursor = catalog.nextPageCursor;
nextPageCursorJson = nextPageCursor ? JSON.parse(atob(nextPageCursor)) : null;
Expand Down Expand Up @@ -4971,7 +4971,7 @@ export class BaileysStartupService extends ChannelStartupService {

public async fetchCollections(instanceName: string, data: getCollectionsDto) {
const jid = data.number ? createJid(data.number) : this.client?.user?.id;
const limit = data.limit <= 20 ? data.limit : 20; //(tem esse limite, não sei porque)
const limit = data.limit || 100;

const onWhatsapp = (await this.whatsappNumber({ numbers: [jid] }))?.shift();

Expand Down
2 changes: 2 additions & 0 deletions src/validate/business.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const catalogSchema: JSONSchema7 = {
properties: {
number: { type: 'string' },
limit: { type: 'number' },
cursor: { type: 'string' },
},
};

Expand All @@ -13,5 +14,6 @@ export const collectionsSchema: JSONSchema7 = {
properties: {
number: { type: 'string' },
limit: { type: 'number' },
cursor: { type: 'string' },
},
};