Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/publish-fork-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish fork Docker image

on:
push:
branches:
- 'feat/group-member-add-mode'
workflow_dispatch:

permissions:
contents: read
packages: write

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Compute lowercase repo
id: vars
run: echo "repo=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64
tags: |
ghcr.io/${{ steps.vars.outputs.repo }}:member-add-mode
ghcr.io/${{ steps.vars.outputs.repo }}:sha-${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
5 changes: 5 additions & 0 deletions src/api/controllers/group.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
GroupSendInvite,
GroupSubjectDto,
GroupToggleEphemeralDto,
GroupUpdateMemberAddModeDto,
GroupUpdateParticipantDto,
GroupUpdateSettingDto,
} from '@api/dto/group.dto';
Expand Down Expand Up @@ -74,6 +75,10 @@ export class GroupController {
return await this.waMonitor.waInstances[instance.instanceName].updateGSetting(update);
}

public async updateMemberAddMode(instance: InstanceDto, update: GroupUpdateMemberAddModeDto) {
return await this.waMonitor.waInstances[instance.instanceName].updateMemberAddMode(update);
}

public async toggleEphemeral(instance: InstanceDto, update: GroupToggleEphemeralDto) {
return await this.waMonitor.waInstances[instance.instanceName].toggleEphemeral(update);
}
Expand Down
4 changes: 4 additions & 0 deletions src/api/dto/group.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ export class GroupUpdateSettingDto extends GroupJid {
export class GroupToggleEphemeralDto extends GroupJid {
expiration: 0 | 86400 | 604800 | 7776000;
}

export class GroupUpdateMemberAddModeDto extends GroupJid {
mode: 'admin_add' | 'all_member_add';
}
10 changes: 10 additions & 0 deletions src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
GroupSendInvite,
GroupSubjectDto,
GroupToggleEphemeralDto,
GroupUpdateMemberAddModeDto,
GroupUpdateParticipantDto,
GroupUpdateSettingDto,
} from '@api/dto/group.dto';
Expand Down Expand Up @@ -4588,6 +4589,15 @@ export class BaileysStartupService extends ChannelStartupService {
}
}

public async updateMemberAddMode(update: GroupUpdateMemberAddModeDto) {
try {
await this.client.groupMemberAddMode(update.groupJid, update.mode);
return { update: 'success', mode: update.mode };
} catch (error) {
throw new BadRequestException('Error updating member add mode', error.toString());
}
}

public async toggleEphemeral(update: GroupToggleEphemeralDto) {
try {
await this.client.groupToggleEphemeral(update.groupJid, update.expiration);
Expand Down
12 changes: 12 additions & 0 deletions src/api/routes/group.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
GroupSendInvite,
GroupSubjectDto,
GroupToggleEphemeralDto,
GroupUpdateMemberAddModeDto,
GroupUpdateParticipantDto,
GroupUpdateSettingDto,
} from '@api/dto/group.dto';
Expand All @@ -25,6 +26,7 @@ import {
updateGroupDescriptionSchema,
updateGroupPictureSchema,
updateGroupSubjectSchema,
updateMemberAddModeSchema,
updateParticipantsSchema,
updateSettingsSchema,
} from '@validate/validate.schema';
Expand Down Expand Up @@ -176,6 +178,16 @@ export class GroupRouter extends RouterBroker {

res.status(HttpStatus.CREATED).json(response);
})
.post(this.routerPath('updateMemberAddMode'), ...guards, async (req, res) => {
const response = await this.groupValidate<GroupUpdateMemberAddModeDto>({
request: req,
schema: updateMemberAddModeSchema,
ClassRef: GroupUpdateMemberAddModeDto,
execute: (instance, data) => groupController.updateMemberAddMode(instance, data),
});

res.status(HttpStatus.CREATED).json(response);
})
.post(this.routerPath('toggleEphemeral'), ...guards, async (req, res) => {
const response = await this.groupValidate<GroupToggleEphemeralDto>({
request: req,
Expand Down
14 changes: 14 additions & 0 deletions src/validate/group.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,17 @@ export const updateGroupDescriptionSchema: JSONSchema7 = {
required: ['groupJid', 'description'],
...isNotEmpty('groupJid', 'description'),
};

export const updateMemberAddModeSchema: JSONSchema7 = {
$id: v4(),
type: 'object',
properties: {
groupJid: { type: 'string' },
mode: {
type: 'string',
enum: ['admin_add', 'all_member_add'],
},
},
required: ['groupJid', 'mode'],
...isNotEmpty('groupJid', 'mode'),
};