Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
feat(groups): read, set and remove a group's picture
Yudhi Armyndharisba82194d9766
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cf742015d..a65fe9a54 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Added+- **Group pictures can be read, set and removed:**+ `GET|PUT|DELETE /api/sessions/:sessionId/groups/:groupId/picture`. Supported on both engines and+ exposed in all five SDKs as `groups.getPicture` / `setPicture` / `deletePicture`. The `PUT` body+ matches the profile-picture one (`url` or `base64` + `mimetype`). Setting or removing requires+ admin rights on the group; a refusal comes back as `403` rather than a silent success.++ The read needed no new engine method — the existing profile-picture lookup already accepts a group+ JID on both engines — so only the two writes were added.+- **Addressbook contacts can be saved, edited and removed:**`PUT /api/sessions/:sessionId/contacts/:contactId` with `{ firstName, lastName? }`, and`DELETE` on the same path. Supported on both engines and exposed in all five SDKs asdiff --git a/docs/06-api-specification.md b/docs/06-api-specification.mdindex 0806a42f1..1d8fab00a 100644--- a/docs/06-api-specification.md+++ b/docs/06-api-specification.md@@ -2058,6 +2058,43 @@ Raw object (no envelope). `engine.getGroupInfo()` returns `GroupInfo | null`; th**Errors:** `400` session is not started · `401` missing/invalid `X-API-Key` · `404` `Group <groupId> not found`+#### GET /api/sessions/:sessionId/groups/:groupId/picture++Get the group's picture URL.++**Auth:** API key++**Response** `200` — `{ "url": "https://…" }`, or `{ "url": null }` when the group has no picture or+it is hidden by privacy settings.++#### PUT /api/sessions/:sessionId/groups/:groupId/picture++Set the group's picture. The account must be a group admin.++**Auth:** API key (OPERATOR)++**Request body** — `SetGroupPictureDto` (same shape as the profile-picture body)++| Field | Type | Required | Constraints | Description |+| --- | --- | --- | --- | --- |+| url | string | One of url/base64 | http(s) URL | Fetched server-side through the SSRF guard |+| base64 | string | One of url/base64 | — | Wins over `url` when both are present |+| mimetype | string | With `base64` | must match `image/*` | Defaults to `image/jpeg` |++**Response** `200` — `{ "success": true, "message": "Group picture updated" }`++**Errors:** `400` session not active, or neither `url` nor `base64` supplied · `401` missing/invalid API key · `403` key lacks OPERATOR role, or the engine refused (admin rights required) · `404` group not found++#### DELETE /api/sessions/:sessionId/groups/:groupId/picture++Remove the group's picture. The account must be a group admin.++**Auth:** API key (OPERATOR)++**Response** `200` — `{ "success": true, "message": "Group picture removed" }`++**Errors:** `401` missing/invalid API key · `403` key lacks OPERATOR role, or the engine refused (admin rights required) · `404` group not found+#### GET /api/sessions/:sessionId/groups/:groupId/invite-codeGet the group invite code and full invite link.diff --git a/docs/18-sdk-design.md b/docs/18-sdk-design.mdindex 87ed2905c..f782877b3 100644--- a/docs/18-sdk-design.md+++ b/docs/18-sdk-design.md@@ -31,7 +31,7 @@ All five SDKs expose the same fluent surface:| `sessions` | list, get, create, delete, start, stop, logout, forceKill, getQrCode, requestPairingCode, stats || `messages` | list, sendText, sendImage/Video/Audio/Document/Sticker, sendLocation, sendContact, sendTemplate, sendPoll, reply, forward, react, delete, editMessage, history, reactions, media, pin, unpin, star, sendBulk, batchStatus, cancelBatch || `contacts` | list, get, check, profilePicture, profilePictures, phone, upsert, delete, block, unblock |-| `groups` | list, get, create, joinGroup, add/remove/promote/demoteParticipants, setSubject, setDescription, getGroupSettings, updateGroupSettings, leave, inviteCode, revokeInviteCode |+| `groups` | list, get, create, joinGroup, add/remove/promote/demoteParticipants, setSubject, setDescription, getGroupSettings, updateGroupSettings, leave, getPicture, setPicture, deletePicture, inviteCode, revokeInviteCode || `webhooks` | list, get, create, update, delete, test || `chats` | list, markRead, markUnread, archive, clearMessages, delete, sendState || `labels` | list, get, forChat, addToChat, removeFromChat *(WhatsApp Business)* |diff --git a/docs/29-engine-capability-matrix.md b/docs/29-engine-capability-matrix.mdindex ebb685a99..38df95749 100644--- a/docs/29-engine-capability-matrix.md+++ b/docs/29-engine-capability-matrix.md@@ -168,8 +168,8 @@ These are hand-maintained and had drifted from the source before this pass; theyfrom `engine-capability-matrix.ts` rather than adjusted by hand. Re-derive them the same way whenadding a method, instead of incrementing the previous figure.-- **88** interface methods, **176** adapter-cells (88 × 2 engines).-- **159** supported cells; **17** not-available cells across **16** methods.+- **90** interface methods, **180** adapter-cells (90 × 2 engines).+- **163** supported cells; **17** not-available cells across **16** methods.- Of the 17 not-available cells: **2 adapter-gaps** (fixable) + **15 library-limitations** + **0 uncertain**.- **0 phantom-support rows** — every `not-available` row throws at the adapter boundary.diff --git a/openapi.json b/openapi.jsonindex 6181d7dbe..367cf85c8 100644--- a/openapi.json+++ b/openapi.json@@ -3935,6 +3935,123 @@]}},+ "/api/sessions/{sessionId}/groups/{groupId}/picture": {+ "get": {+ "operationId": "GroupController_getPicture",+ "parameters": [+ {+ "name": "sessionId",+ "required": true,+ "in": "path",+ "description": "Session ID",+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "groupId",+ "required": true,+ "in": "path",+ "description": "Group ID",+ "schema": {+ "type": "string"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Picture URL, or null when the group has none"+ }+ },+ "summary": "Get the group's picture URL",+ "tags": [+ "groups"+ ]+ },+ "put": {+ "operationId": "GroupController_setPicture",+ "parameters": [+ {+ "name": "sessionId",+ "required": true,+ "in": "path",+ "description": "Session ID",+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "groupId",+ "required": true,+ "in": "path",+ "description": "Group ID",+ "schema": {+ "type": "string"+ }+ }+ ],+ "requestBody": {+ "required": true,+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/SetGroupPictureDto"+ }+ }+ }+ },+ "responses": {+ "200": {+ "description": "Group picture updated"+ },+ "400": {+ "description": "Session not active, or neither url nor base64 supplied"+ },+ "403": {+ "description": "The engine refused the change — admin rights required"+ }+ },+ "summary": "Set the group's picture",+ "tags": [+ "groups"+ ]+ },+ "delete": {+ "operationId": "GroupController_deletePicture",+ "parameters": [+ {+ "name": "sessionId",+ "required": true,+ "in": "path",+ "description": "Session ID",+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "groupId",+ "required": true,+ "in": "path",+ "description": "Group ID",+ "schema": {+ "type": "string"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "Group picture removed"+ },+ "403": {+ "description": "The engine refused the change — admin rights required"+ }+ },+ "summary": "Remove the group's picture",+ "tags": [+ "groups"+ ]+ }+ },"/api/sessions/{sessionId}/groups/{groupId}/invite-code": {"get": {"operationId": "GroupController_getInviteCode",@@ -8069,6 +8186,25 @@"description"]},+ "SetGroupPictureDto": {+ "type": "object",+ "properties": {+ "url": {+ "type": "string",+ "description": "Image URL (http/https)",+ "example": "https://example.com/group.jpg"+ },+ "base64": {+ "type": "string",+ "description": "Base64 encoded image data"+ },+ "mimetype": {+ "type": "string",+ "description": "Image MIME type (required when using base64)",+ "example": "image/jpeg"+ }+ }+ },"SetProfileNameDto": {"type": "object","properties": {diff --git a/sdk/README.md b/sdk/README.mdindex edf235729..c1d038142 100644--- a/sdk/README.md+++ b/sdk/README.md@@ -27,7 +27,7 @@ All five SDKs expose the same fluent resource surface:| `sessions` | list, get, create, delete, start, stop, logout, forceKill, getQrCode, requestPairingCode, stats || `messages` | list, sendText, sendImage/Video/Audio/Document/Sticker, sendLocation, sendContact, sendTemplate, sendPoll, reply, forward, react, delete, editMessage, history, reactions, media, pin, unpin, star, sendBulk, batchStatus, cancelBatch || `contacts` | list, get, check, profilePicture, profilePictures, phone, upsert, delete, block, unblock |-| `groups` | list, get, create, joinGroup, add/remove/promote/demoteParticipants, setSubject, setDescription, get/updateGroupSettings, leave, inviteCode, revokeInviteCode |+| `groups` | list, get, create, joinGroup, add/remove/promote/demoteParticipants, setSubject, setDescription, get/updateGroupSettings, leave, getPicture, setPicture, deletePicture, inviteCode, revokeInviteCode || `webhooks` | list, get, create, update, delete, test || `chats` | list, markRead, markUnread, archive, clearMessages, delete, sendState || `labels` | list, get, forChat, addToChat, removeFromChat _(WhatsApp Business)_ |diff --git a/sdk/go/groups.go b/sdk/go/groups.goindex a12f4423a..7dbc158ef 100644--- a/sdk/go/groups.go+++ b/sdk/go/groups.go@@ -133,6 +133,33 @@ func (s *GroupsService) Leave(ctx context.Context, sessionID, groupID string) (*return &out, nil}+// GetPicture returns the group's picture URL, empty when it has none.+func (s *GroupsService) GetPicture(ctx context.Context, sessionID, groupID string) (*GroupPictureResponse, error) {+ var out GroupPictureResponse+ if err := s.client.do(ctx, "GET", s.base(sessionID)+"/"+pathEscape(groupID)+"/picture", nil, nil, &out); err != nil {+ return nil, err+ }+ return &out, nil+}++// SetPicture sets the group's picture. Requires admin rights on the group.+func (s *GroupsService) SetPicture(ctx context.Context, sessionID, groupID string, body SetGroupPictureRequest) (*SuccessResult, error) {+ var out SuccessResult+ if err := s.client.do(ctx, "PUT", s.base(sessionID)+"/"+pathEscape(groupID)+"/picture", nil, body, &out); err != nil {+ return nil, err+ }+ return &out, nil+}++// DeletePicture removes the group's picture. Requires admin rights on the group.+func (s *GroupsService) DeletePicture(ctx context.Context, sessionID, groupID string) (*SuccessResult, error) {+ var out SuccessResult+ if err := s.client.do(ctx, "DELETE", s.base(sessionID)+"/"+pathEscape(groupID)+"/picture", nil, nil, &out); err != nil {+ return nil, err+ }+ return &out, nil+}+// InviteCode returns the group invite code/link.func (s *GroupsService) InviteCode(ctx context.Context, sessionID, groupID string) (*InviteCodeResponse, error) {var out InviteCodeResponsediff --git a/sdk/go/routing_test.go b/sdk/go/routing_test.goindex 0acb02f11..5dec8b5a6 100644--- a/sdk/go/routing_test.go+++ b/sdk/go/routing_test.go@@ -62,6 +62,9 @@ func TestRouting(t *testing.T) {{"Contacts.Block", func(c *Client) { c.Contacts.Block(ctx, "s1", "u1") }, "POST", "/api/sessions/s1/contacts/u1/block"},{"Contacts.Unblock", func(c *Client) { c.Contacts.Unblock(ctx, "s1", "u1") }, "DELETE", "/api/sessions/s1/contacts/u1/block"},+ {"Groups.GetPicture", func(c *Client) { c.Groups.GetPicture(ctx, "s1", "g1") }, "GET", "/api/sessions/s1/groups/g1/picture"},+ {"Groups.SetPicture", func(c *Client) { c.Groups.SetPicture(ctx, "s1", "g1", SetGroupPictureRequest{}) }, "PUT", "/api/sessions/s1/groups/g1/picture"},+ {"Groups.DeletePicture", func(c *Client) { c.Groups.DeletePicture(ctx, "s1", "g1") }, "DELETE", "/api/sessions/s1/groups/g1/picture"},{"Groups.List", func(c *Client) { c.Groups.List(ctx, "s1", nil) }, "GET", "/api/sessions/s1/groups"},{"Groups.Get", func(c *Client) { c.Groups.Get(ctx, "s1", "g1") }, "GET", "/api/sessions/s1/groups/g1"},{"Groups.Create", func(c *Client) { c.Groups.Create(ctx, "s1", CreateGroupRequest{}) }, "POST", "/api/sessions/s1/groups"},diff --git a/sdk/go/types_group.go b/sdk/go/types_group.goindex e2c24a692..73d17d58b 100644--- a/sdk/go/types_group.go+++ b/sdk/go/types_group.go@@ -91,3 +91,16 @@ func (q *ListGroupsQuery) values() url.Values {setInt(v, "offset", q.Offset)return v}++// SetGroupPictureRequest sets a group's picture. Provide URL or Base64 (Base64+// wins when both are set); Mimetype is required with Base64.+type SetGroupPictureRequest struct {+ URL string `json:"url,omitempty"`+ Base64 string `json:"base64,omitempty"`+ Mimetype string `json:"mimetype,omitempty"`+}++// GroupPictureResponse carries the group's picture URL, empty when it has none.+type GroupPictureResponse struct {+ URL string `json:"url"`+}diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/GroupPictureResponse.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/GroupPictureResponse.javanew file mode 100644index 000000000..ceb069476--- /dev/null+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/GroupPictureResponse.java@@ -0,0 +1,4 @@+package com.rmyndharis.openwa.model;++/** The group's picture URL, or null when the group has none. */+public record GroupPictureResponse(String url) {}diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/SetGroupPictureRequest.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SetGroupPictureRequest.javanew file mode 100644index 000000000..383e4e932--- /dev/null+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/SetGroupPictureRequest.java@@ -0,0 +1,36 @@+package com.rmyndharis.openwa.model;++/**+ * Request body for setting a group's picture. Provide exactly one of {@code url} or+ * {@code base64} (base64 wins when both are present); {@code mimetype} is required with base64.+ */+public record SetGroupPictureRequest(String url, String base64, String mimetype) {+ public static Builder builder() {+ return new Builder();+ }++ public static final class Builder {+ private String url;+ private String base64;+ private String mimetype;++ public Builder url(String v) {+ this.url = v;+ return this;+ }++ public Builder base64(String v) {+ this.base64 = v;+ return this;+ }++ public Builder mimetype(String v) {+ this.mimetype = v;+ return this;+ }++ public SetGroupPictureRequest build() {+ return new SetGroupPictureRequest(url, base64, mimetype);+ }+ }+}diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/resources/GroupsResource.java b/sdk/java/src/main/java/com/rmyndharis/openwa/resources/GroupsResource.javaindex 8734e81e1..9b36b6a44 100644--- a/sdk/java/src/main/java/com/rmyndharis/openwa/resources/GroupsResource.java+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/resources/GroupsResource.java@@ -10,7 +10,9 @@ import com.rmyndharis.openwa.model.GroupInfo;import com.rmyndharis.openwa.model.GroupSettings;import com.rmyndharis.openwa.model.GroupSubjectRequest;import com.rmyndharis.openwa.model.GroupSummary;+import com.rmyndharis.openwa.model.GroupPictureResponse;import com.rmyndharis.openwa.model.InviteCodeResponse;+import com.rmyndharis.openwa.model.SetGroupPictureRequest;import com.rmyndharis.openwa.model.JoinGroupRequest;import com.rmyndharis.openwa.model.JoinGroupResponse;import com.rmyndharis.openwa.model.ListGroupsQuery;@@ -156,6 +158,36 @@ public final class GroupsResource {SuccessResult.class);}+ /** Get the group's picture URL (null when it has none). */+ public GroupPictureResponse getPicture(String sessionId, String groupId) {+ return client.request(+ HttpMethod.GET,+ "/api/sessions/" + encodeSegment(sessionId) + "/groups/" + encodeSegment(groupId) + "/picture",+ null,+ null,+ GroupPictureResponse.class);+ }++ /** Set the group's picture. Requires admin rights on the group. */+ public SuccessResult setPicture(String sessionId, String groupId, SetGroupPictureRequest body) {+ return client.request(+ HttpMethod.PUT,+ "/api/sessions/" + encodeSegment(sessionId) + "/groups/" + encodeSegment(groupId) + "/picture",+ null,+ body,+ SuccessResult.class);+ }++ /** Remove the group's picture. Requires admin rights on the group. */+ public SuccessResult deletePicture(String sessionId, String groupId) {+ return client.request(+ HttpMethod.DELETE,+ "/api/sessions/" + encodeSegment(sessionId) + "/groups/" + encodeSegment(groupId) + "/picture",+ null,+ null,+ SuccessResult.class);+ }+/** Get the group invite code and link. */public InviteCodeResponse inviteCode(String sessionId, String groupId) {return client.request(diff --git a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/GroupsResourceTest.java b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/GroupsResourceTest.javaindex 305703a01..37337064b 100644--- a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/GroupsResourceTest.java+++ b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/GroupsResourceTest.java@@ -8,6 +8,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;import com.rmyndharis.openwa.ClientConfig;import com.rmyndharis.openwa.OpenWAClient;import com.rmyndharis.openwa.http.HttpMethod;+import com.rmyndharis.openwa.model.SetGroupPictureRequest;import com.rmyndharis.openwa.model.CreateGroupRequest;import com.rmyndharis.openwa.model.GroupSettings;import com.rmyndharis.openwa.model.ListGroupsQuery;@@ -177,4 +178,19 @@ class GroupsResourceTest {assertEquals("http://h/api/sessions/s/groups/[email protected]/invite-code/revoke", tx.lastRequest().url());assertEquals(HttpMethod.POST, tx.lastRequest().method());}++ @Test+ void pictureGetSetDelete() {+ tx.respond(200, "{\"url\":\"https://x/p.jpg\"}");+ client.groups.getPicture("s", "[email protected]");+ assertEquals("http://h/api/sessions/s/groups/[email protected]/picture", tx.lastRequest().url());++ tx.respond(200, "{\"success\":true}");+ client.groups.setPicture("s", "[email protected]", SetGroupPictureRequest.builder().url("https://x/n.jpg").build());+ assertEquals(HttpMethod.PUT, tx.lastRequest().method());++ tx.respond(200, "{\"success\":true}");+ client.groups.deletePicture("s", "[email protected]");+ assertEquals(HttpMethod.DELETE, tx.lastRequest().method());+ }}diff --git a/sdk/javascript/src/resources/groups.ts b/sdk/javascript/src/resources/groups.tsindex 0d39c59e1..c4438c774 100644--- a/sdk/javascript/src/resources/groups.ts+++ b/sdk/javascript/src/resources/groups.ts@@ -13,6 +13,7 @@ import type {GroupSettingsResponse,GroupSummary,InviteCodeResponse,+ SetGroupPictureRequest,JoinGroupRequest,JoinGroupResponse,SuccessResult,@@ -145,6 +146,31 @@ export class GroupsResource {}/** Get the group invite code and link. */+ /** Get the group's picture URL (null when it has none). */+ getPicture(sessionId: string, groupId: string): Promise<{ url: string | null }> {+ return this.client.request<{ url: string | null }>({+ method: 'GET',+ path: `/api/sessions/${encodeSegment(sessionId)}/groups/${encodeSegment(groupId)}/picture`,+ });+ }++ /** Set the group's picture. Requires admin rights on the group. */+ setPicture(sessionId: string, groupId: string, body: SetGroupPictureRequest): Promise<SuccessResult> {+ return this.client.request<SuccessResult>({+ method: 'PUT',+ path: `/api/sessions/${encodeSegment(sessionId)}/groups/${encodeSegment(groupId)}/picture`,+ body,+ });+ }++ /** Remove the group's picture. Requires admin rights on the group. */+ deletePicture(sessionId: string, groupId: string): Promise<SuccessResult> {+ return this.client.request<SuccessResult>({+ method: 'DELETE',+ path: `/api/sessions/${encodeSegment(sessionId)}/groups/${encodeSegment(groupId)}/picture`,+ });+ }+inviteCode(sessionId: string, groupId: string): Promise<InviteCodeResponse> {return this.client.request<InviteCodeResponse>({method: 'GET',diff --git a/sdk/javascript/src/types.ts b/sdk/javascript/src/types.tsindex cd3fc738d..fc695cb49 100644--- a/sdk/javascript/src/types.ts+++ b/sdk/javascript/src/types.ts@@ -188,6 +188,14 @@ export interface PinMessageRequest {durationSeconds?: PinDurationSeconds;}+export interface SetGroupPictureRequest {+ /** Provide exactly one of `url` or `base64` (base64 wins when both are present). */+ url?: string;+ base64?: string;+ /** Required when using `base64`. Must be an image type. */+ mimetype?: string;+}+export interface UpsertContactRequest {/** The contact's first name. */firstName: string;diff --git a/sdk/javascript/test/resources.test.ts b/sdk/javascript/test/resources.test.tsindex b978f8b3c..e9597caab 100644--- a/sdk/javascript/test/resources.test.ts+++ b/sdk/javascript/test/resources.test.ts@@ -281,6 +281,22 @@ describe('ChatsResource.clearMessages', () => {});});+describe('GroupsResource picture', () => {+ it('GETs, PUTs and DELETEs the picture sub-resource', async () => {+ const t = new MockTransport()+ .on('GET', /\/groups\/[^/]+\/picture$/, { body: { url: 'https://x/p.jpg' } })+ .on('PUT', /\/groups\/[^/]+\/picture$/, { body: { success: true } })+ .on('DELETE', /\/groups\/[^/]+\/picture$/, { body: { success: true } });+ const c = client(t);+ expect(await c.groups.getPicture('s', '[email protected]')).toEqual({ url: 'https://x/p.jpg' });+ await c.groups.setPicture('s', '[email protected]', { url: 'https://x/new.jpg' });+ expect(t.lastCall!.method).toBe('PUT');+ expect(t.lastCall!.url).toBe('http://x/api/sessions/s/groups/[email protected]/picture');+ await c.groups.deletePicture('s', '[email protected]');+ expect(t.lastCall!.method).toBe('DELETE');+ });+});+describe('ContactsResource addressbook', () => {it('PUTs the contact and DELETEs it by the same path', async () => {const t = new MockTransport()diff --git a/sdk/php/src/Resources/GroupsResource.php b/sdk/php/src/Resources/GroupsResource.phpindex ed208bab1..a5738336c 100644--- a/sdk/php/src/Resources/GroupsResource.php+++ b/sdk/php/src/Resources/GroupsResource.php@@ -122,6 +122,37 @@ class GroupsResourcereturn $this->http->request('POST', "/api/sessions/{$this->http->encodeSegment($sessionId)}/groups/{$this->http->encodeSegment($groupId)}/leave");}+ /**+ * Get the group's picture URL (null when it has none).+ *+ * @return array<string,mixed>+ */+ public function getPicture(string $sessionId, string $groupId): array+ {+ return $this->http->request('GET', "/api/sessions/{$this->http->encodeSegment($sessionId)}/groups/{$this->http->encodeSegment($groupId)}/picture") ?? [];+ }++ /**+ * Set the group's picture. Requires admin rights on the group.+ *+ * @param array<string,mixed> $body url OR base64 (base64 wins), plus mimetype with base64.+ * @return array<string,mixed>+ */+ public function setPicture(string $sessionId, string $groupId, array $body): array+ {+ return $this->http->request('PUT', "/api/sessions/{$this->http->encodeSegment($sessionId)}/groups/{$this->http->encodeSegment($groupId)}/picture", [], $body) ?? [];+ }++ /**+ * Remove the group's picture. Requires admin rights on the group.+ *+ * @return array<string,mixed>+ */+ public function deletePicture(string $sessionId, string $groupId): array+ {+ return $this->http->request('DELETE', "/api/sessions/{$this->http->encodeSegment($sessionId)}/groups/{$this->http->encodeSegment($groupId)}/picture") ?? [];+ }+/** @return array<string,mixed> */public function inviteCode(string $sessionId, string $groupId): array{diff --git a/sdk/php/tests/ResourcesTest.php b/sdk/php/tests/ResourcesTest.phpindex 02b535288..4b9612ec8 100644--- a/sdk/php/tests/ResourcesTest.php+++ b/sdk/php/tests/ResourcesTest.php@@ -248,6 +248,21 @@ class ResourcesTest extends TestCase$this->assertSame('/api/sessions/s/chats/[email protected]/messages', $backend->lastCall()['path']);}+ public function testGroupsPicture(): void+ {+ $backend = new MockBackend();+ $backend->on(200, ['url' => 'https://x/p.jpg']);+ $backend->on(200, ['success' => true]);+ $backend->on(200, ['success' => true]);+ $client = $backend->makeClient();+ $client->groups->getPicture('s', '[email protected]');+ $this->assertSame('/api/sessions/s/groups/[email protected]/picture', $backend->lastCall()['path']);+ $client->groups->setPicture('s', '[email protected]', ['url' => 'https://x/new.jpg']);+ $this->assertSame('PUT', $backend->lastCall()['method']);+ $client->groups->deletePicture('s', '[email protected]');+ $this->assertSame('DELETE', $backend->lastCall()['method']);+ }+public function testContactsAddressbook(): void{$backend = new MockBackend();diff --git a/sdk/python/openwa/resources/groups.py b/sdk/python/openwa/resources/groups.pyindex 0ad9330c6..b5ad85373 100644--- a/sdk/python/openwa/resources/groups.py+++ b/sdk/python/openwa/resources/groups.py@@ -5,10 +5,11 @@ Backed by ``src/modules/group/group.controller.ts``.from __future__ import annotations-from typing import TYPE_CHECKING, TypedDict+from typing import Any, TYPE_CHECKING, TypedDictfrom .._http import quote_segmentfrom ..types import (+ SetGroupPictureRequest,CreateGroupRequest,GroupInfo,GroupSettings,@@ -79,6 +80,24 @@ class GroupsResource:def leave(self, session_id: str, group_id: str) -> SuccessResult:return self._http.request("POST", f"/api/sessions/{quote_segment(session_id)}/groups/{quote_segment(group_id)}/leave")+ def get_picture(self, session_id: str, group_id: str) -> dict[str, Any]:+ """Get the group's picture URL (None when it has none)."""+ return self._http.request(+ "GET", f"/api/sessions/{quote_segment(session_id)}/groups/{quote_segment(group_id)}/picture"+ )++ def set_picture(self, session_id: str, group_id: str, body: SetGroupPictureRequest) -> SuccessResult:+ """Set the group's picture. Requires admin rights on the group."""+ return self._http.request(+ "PUT", f"/api/sessions/{quote_segment(session_id)}/groups/{quote_segment(group_id)}/picture", body=body+ )++ def delete_picture(self, session_id: str, group_id: str) -> SuccessResult:+ """Remove the group's picture. Requires admin rights on the group."""+ return self._http.request(+ "DELETE", f"/api/sessions/{quote_segment(session_id)}/groups/{quote_segment(group_id)}/picture"+ )+def invite_code(self, session_id: str, group_id: str) -> InviteCodeResponse:return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/groups/{quote_segment(group_id)}/invite-code"diff --git a/sdk/python/openwa/types.py b/sdk/python/openwa/types.pyindex f35b7e73e..2f14cbc9a 100644--- a/sdk/python/openwa/types.py+++ b/sdk/python/openwa/types.py@@ -643,6 +643,14 @@ class PinMessageRequest(TypedDict, total=False):durationSeconds: int+class SetGroupPictureRequest(TypedDict, total=False):+ """Group picture: provide url OR base64 (base64 wins); mimetype required with base64."""++ url: str+ base64: str+ mimetype: str++class UpsertContactRequest(TypedDict, total=False):"""Save or edit an addressbook contact. lastName is optional."""diff --git a/sdk/python/tests/test_sdk.py b/sdk/python/tests/test_sdk.pyindex 83545e503..16c8eae69 100644--- a/sdk/python/tests/test_sdk.py+++ b/sdk/python/tests/test_sdk.py@@ -561,6 +561,18 @@ class TestChatsAndHealth:assert backend.last_call.method == "DELETE"assert backend.last_call.url == "http://localhost:2785/api/sessions/s/chats/[email protected]/messages"+ def test_groups_picture(self):+ backend = MockBackend().on("GET", "/picture", body={"url": "https://x/p.jpg"})+ backend.on("PUT", "/picture", body={"success": True})+ backend.on("DELETE", "/picture", body={"success": True})+ client = make_client(backend)+ assert client.groups.get_picture("s", "[email protected]") == {"url": "https://x/p.jpg"}+ client.groups.set_picture("s", "[email protected]", {"url": "https://x/new.jpg"})+ assert backend.last_call.method == "PUT"+ client.groups.delete_picture("s", "[email protected]")+ assert backend.last_call.method == "DELETE"+ assert backend.last_call.url == "http://localhost:2785/api/sessions/s/groups/[email protected]/picture"+def test_contacts_addressbook(self):backend = MockBackend().on("PUT", "/contacts/", body={"success": True})backend.on("DELETE", "/contacts/", body={"success": True})diff --git a/src/engine/adapters/baileys-groups.ts b/src/engine/adapters/baileys-groups.tsindex 3fae75efb..802f5ee51 100644--- a/src/engine/adapters/baileys-groups.ts+++ b/src/engine/adapters/baileys-groups.ts@@ -3,9 +3,11 @@ import {Group,GroupInfo,GroupMemberAddMode,+ MediaInput,ParticipantOperationResult,} from '../interfaces/whatsapp-engine.interface';import { mapBaileysGroup, mapBaileysGroupInfo } from './baileys-group-mapper';+import { resolveMediaBuffer } from './baileys-messaging';import { EngineRefusedError } from '../../common/errors/engine-refused.error';import { InvalidInviteCodeError } from '../../common/errors/invalid-invite-code.error';import { type createLogger } from '../../common/services/logger.service';@@ -207,6 +209,18 @@ export class BaileysGroups {await this.sock().groupSettingUpdate(groupId, adminsOnly ? 'locked' : 'unlocked');}+ async setGroupPicture(groupId: string, media: MediaInput): Promise<void> {+ this.host.ensureReady();+ // Same socket call as the own-account picture, addressed at the group JID.+ const { data } = await resolveMediaBuffer(media);+ await this.sock().updateProfilePicture(groupId, data);+ }++ async deleteGroupPicture(groupId: string): Promise<void> {+ this.host.ensureReady();+ await this.sock().removeProfilePicture(groupId);+ }+async setGroupMemberAddMode(groupId: string, mode: GroupMemberAddMode): Promise<void> {this.host.ensureReady();// A dedicated socket call, not a groupSettingUpdate option.diff --git a/src/engine/adapters/baileys.adapter.spec.ts b/src/engine/adapters/baileys.adapter.spec.tsindex ab8722777..21a81f568 100644--- a/src/engine/adapters/baileys.adapter.spec.ts+++ b/src/engine/adapters/baileys.adapter.spec.ts@@ -48,6 +48,7 @@ class FakeSock extends EventEmitter {public updateProfileName = jest.fn().mockResolvedValue(undefined);public updateProfileStatus = jest.fn().mockResolvedValue(undefined);public updateProfilePicture = jest.fn().mockResolvedValue(undefined);+ public removeProfilePicture = jest.fn().mockResolvedValue(undefined);public updateBlockStatus = jest.fn().mockResolvedValue(undefined);public addOrEditContact = jest.fn().mockResolvedValue(undefined);public removeContact = jest.fn().mockResolvedValue(undefined);@@ -3738,6 +3739,18 @@ describe('BaileysAdapter sendSeen + markUnread + deleteChat', () => {expect(fakeSock.chatModify).not.toHaveBeenCalled();});+ it('setGroupPicture targets the GROUP jid, not the own account', async () => {+ const adapter = await readyWithMessage();+ await adapter.setGroupPicture('[email protected]', { mimetype: 'image/png', data: 'QUJD' });+ expect(fakeSock.updateProfilePicture).toHaveBeenCalledWith('[email protected]', expect.any(Buffer));+ });++ it('deleteGroupPicture removes by the GROUP jid', async () => {+ const adapter = await readyWithMessage();+ await adapter.deleteGroupPicture('[email protected]');+ expect(fakeSock.removeProfilePicture).toHaveBeenCalledWith('[email protected]');+ });+it('upsertContact addresses the entry by JID and composes fullName', async () => {const adapter = await readyWithMessage();await adapter.upsertContact('[email protected]', 'Ada', 'Lovelace');diff --git a/src/engine/adapters/baileys.adapter.ts b/src/engine/adapters/baileys.adapter.tsindex d0dde9e86..67ee4ea32 100644--- a/src/engine/adapters/baileys.adapter.ts+++ b/src/engine/adapters/baileys.adapter.ts@@ -421,6 +421,14 @@ export class BaileysAdapter implements IWhatsAppEngine {return this.groups.setGroupMemberAddMode(groupId, mode);}+ async setGroupPicture(groupId: string, media: MediaInput): Promise<void> {+ return this.groups.setGroupPicture(groupId, media);+ }++ async deleteGroupPicture(groupId: string): Promise<void> {+ return this.groups.deleteGroupPicture(groupId);+ }+async setGroupEphemeral(groupId: string, durationSec: number): Promise<void> {return this.groups.setGroupEphemeral(groupId, durationSec);}diff --git a/src/engine/adapters/whatsapp-web-js.adapter.spec.ts b/src/engine/adapters/whatsapp-web-js.adapter.spec.tsindex d0d53ca42..c6f394c90 100644--- a/src/engine/adapters/whatsapp-web-js.adapter.spec.ts+++ b/src/engine/adapters/whatsapp-web-js.adapter.spec.ts@@ -744,6 +744,41 @@ describe('WhatsAppWebJsAdapter channel-JID guard (#554 — wwebjs Channel lacks});});+ describe('group picture', () => {+ const groupChat = (over: Record<string, unknown> = {}) => ({+ getChatById: jest.fn().mockResolvedValue({ isGroup: true, ...over }),+ });++ it('uses GroupChat.setPicture, not the own-account Client.setProfilePicture', async () => {+ const setPicture = jest.fn().mockResolvedValue(true);+ const setProfilePicture = jest.fn();+ await readyAdapter({ ...groupChat({ setPicture }), setProfilePicture }).setGroupPicture('[email protected]', {+ mimetype: 'image/png',+ data: 'QUJD',+ });+ expect(setPicture).toHaveBeenCalled();+ expect(setProfilePicture).not.toHaveBeenCalled();+ });++ it('treats a false setPicture as a refusal (admin rights required)', async () => {+ const setPicture = jest.fn().mockResolvedValue(false);+ await expect(+ readyAdapter(groupChat({ setPicture })).setGroupPicture('[email protected]', { mimetype: 'image/png', data: 'QUJD' }),+ ).rejects.toBeInstanceOf(EngineRefusedError);+ });++ it('deletes via GroupChat.deletePicture and maps false to a refusal', async () => {+ const deletePicture = jest.fn().mockResolvedValue(true);+ await readyAdapter(groupChat({ deletePicture })).deleteGroupPicture('[email protected]');+ expect(deletePicture).toHaveBeenCalled();++ const refused = jest.fn().mockResolvedValue(false);+ await expect(+ readyAdapter(groupChat({ deletePicture: refused })).deleteGroupPicture('[email protected]'),+ ).rejects.toBeInstanceOf(EngineRefusedError);+ });+ });+describe('addressbook contacts', () => {it('passes a bare PHONE NUMBER, not the JID — wwjs addresses the entry by number', async () => {const saveOrEditAddressbookContact = jest.fn().mockResolvedValue(undefined);diff --git a/src/engine/adapters/whatsapp-web-js.adapter.ts b/src/engine/adapters/whatsapp-web-js.adapter.tsindex 5140275ff..48ae069b0 100644--- a/src/engine/adapters/whatsapp-web-js.adapter.ts+++ b/src/engine/adapters/whatsapp-web-js.adapter.ts@@ -1521,6 +1521,14 @@ export class WhatsAppWebJsAdapter extends EventEmitter implements IWhatsAppEnginreturn this.groups.setGroupMemberAddMode(groupId, mode);}+ setGroupPicture(groupId: string, media: MediaInput): Promise<void> {+ return this.groups.setGroupPicture(groupId, media);+ }++ deleteGroupPicture(groupId: string): Promise<void> {+ return this.groups.deleteGroupPicture(groupId);+ }+setGroupEphemeral(groupId: string, durationSec: number): Promise<void> {return this.groups.setGroupEphemeral(groupId, durationSec);}diff --git a/src/engine/adapters/wwebjs-groups.ts b/src/engine/adapters/wwebjs-groups.tsindex 35a8d20b4..465911763 100644--- a/src/engine/adapters/wwebjs-groups.ts+++ b/src/engine/adapters/wwebjs-groups.ts@@ -3,6 +3,7 @@ import {Group,GroupInfo,GroupMemberAddMode,+ MediaInput,GroupParticipant,ParticipantOperationResult,} from '../interfaces/whatsapp-engine.interface';@@ -12,6 +13,7 @@ import { EngineTransportError } from '../../common/errors/engine-transport.errorimport { EngineNotSupportedError } from '../../common/errors/engine-not-supported.error';import { GroupNotFoundError } from '../../common/errors/group-not-found.error';import { InvalidInviteCodeError } from '../../common/errors/invalid-invite-code.error';+import { toMessageMedia } from './wwebjs-messaging';import { type WwebjsEngineHost } from './wwebjs-host';/**@@ -377,6 +379,23 @@ export class WwebjsGroups {}}+ async setGroupPicture(groupId: string, media: MediaInput): Promise<void> {+ const groupChat = await this.requireGroupChat(groupId);+ // GroupChat.setPicture, NOT Client.setProfilePicture — the latter targets the own account.+ const ok = await groupChat.setPicture(await toMessageMedia(media));+ if (!ok) {+ throw new EngineRefusedError(`Failed to set the picture for group ${groupId} — admin rights required`);+ }+ }++ async deleteGroupPicture(groupId: string): Promise<void> {+ const groupChat = await this.requireGroupChat(groupId);+ const ok = await groupChat.deletePicture();+ if (!ok) {+ throw new EngineRefusedError(`Failed to delete the picture for group ${groupId} — admin rights required`);+ }+ }+// Set who may add participants. NOT a groupSettingUpdate option on either engine — wwjs has its// own GroupChat setter, and it is inverted relative to our neutral vocabulary: adminsOnly=true// means mode 'admins'.diff --git a/src/engine/engine-capability-matrix.ts b/src/engine/engine-capability-matrix.tsindex 8d28ba18a..64d22b06c 100644--- a/src/engine/engine-capability-matrix.ts+++ b/src/engine/engine-capability-matrix.ts@@ -84,6 +84,12 @@ export const ENGINE_CAPABILITY_MATRIX: Record<string, MethodCapability> = {evidence:'wwjs Client.deleteAddressbookContact(phoneNumber) → void (index.d.ts:320; the parameter is misspelled `honeNumber` upstream, positional so harmless); baileys removeContact(jid) (Socket/chats.d.ts:67). wwjs addresses the entry by PHONE, baileys by JID — the adapter converts',},+ deleteGroupPicture: {+ wwjs: { status: 'supported' },+ baileys: { status: 'supported' },+ evidence:+ 'wwjs GroupChat.deletePicture() → boolean (index.d.ts:2249; false → adapter throws EngineRefusedError); baileys removeProfilePicture(groupJid) (Socket/groups.d.ts:83) — the same call used for the own account, addressed at the group JID',+ },deleteMessage: { wwjs: { status: 'supported' }, baileys: { status: 'supported' } },deleteStatus: { wwjs: { status: 'supported' }, baileys: { status: 'supported' } },demoteParticipants: {@@ -288,6 +294,12 @@ export const ENGINE_CAPABILITY_MATRIX: Record<string, MethodCapability> = {evidence:"wwjs GroupChat.setMessagesAdminsOnly(adminsOnly?) (index.d.ts:2210; sets groupMetadata.announce, GroupChat.js:513); baileys groupSettingUpdate(jid, 'announcement'|'not_announcement') (Socket/groups.d.ts:41)",},+ setGroupPicture: {+ wwjs: { status: 'supported' },+ baileys: { status: 'supported' },+ evidence:+ 'wwjs GroupChat.setPicture(MessageMedia) → boolean (index.d.ts:2247) — the GroupChat method, not Client.setProfilePicture which targets the own account; baileys updateProfilePicture(groupJid, WAMediaUpload) (Socket/groups.d.ts:79)',+ },setGroupSubject: {wwjs: { status: 'supported' },baileys: { status: 'supported' },diff --git a/src/engine/interfaces/whatsapp-engine.interface.ts b/src/engine/interfaces/whatsapp-engine.interface.tsindex e4f6431d9..1e29b744f 100644--- a/src/engine/interfaces/whatsapp-engine.interface.ts+++ b/src/engine/interfaces/whatsapp-engine.interface.ts@@ -691,6 +691,14 @@ export interface IWhatsAppEngine {setGroupMessagesAdminsOnly(groupId: string, adminsOnly: boolean): Promise<void>;/** Set the "only admins can edit group info" group setting (WhatsApp locked/restrict). */setGroupInfoAdminsOnly(groupId: string, adminsOnly: boolean): Promise<void>;+ /**+ * Set the group's picture. Requires admin rights on both engines; the engines report a refusal+ * differently, so the adapters normalise it. Reading the current picture needs no dedicated+ * method — `getProfilePicture` accepts a group JID.+ */+ setGroupPicture(groupId: string, media: MediaInput): Promise<void>;+ /** Remove the group's picture. */+ deleteGroupPicture(groupId: string): Promise<void>;/** Set who may add participants to the group. */setGroupMemberAddMode(groupId: string, mode: GroupMemberAddMode): Promise<void>;/**diff --git a/src/engine/types/whatsapp-web-js.types.ts b/src/engine/types/whatsapp-web-js.types.tsindex 68f4f3523..1cd1153ce 100644--- a/src/engine/types/whatsapp-web-js.types.ts+++ b/src/engine/types/whatsapp-web-js.types.ts@@ -82,6 +82,10 @@ export interface GroupChat extends Omit<Chat, 'isReadOnly' | 'getLabels'> {setInfoAdminsOnly(adminsOnly?: boolean): Promise<boolean>;/** Only admins may add participants when true (index.d.ts:2205). */setAddMembersAdminsOnly(adminsOnly?: boolean): Promise<boolean>;+ /** Resolves false when the account lacks admin rights (does not throw). */+ setPicture(media: unknown): Promise<boolean>;+ /** Resolves false when the account lacks admin rights (does not throw). */+ deletePicture(): Promise<boolean>;}/**diff --git a/src/modules/group/dto/group.dto.ts b/src/modules/group/dto/group.dto.tsindex 3a4dd609f..1cd99ccef 100644--- a/src/modules/group/dto/group.dto.ts+++ b/src/modules/group/dto/group.dto.ts@@ -10,6 +10,9 @@ import {IsIn,IsInt,Min,+ IsOptional,+ IsUrl,+ Matches,ValidateIf,} from 'class-validator';import { ToStrictBoolean, ToStrictNumber } from '../../../common/utils/strict-boolean';@@ -96,6 +99,32 @@ export class JoinGroupDto {* ValidateIf (not @IsOptional) so an explicit `null` fails validation (400) instead of being applied* as a value; only `undefined` (absent) skips the field.*/+/**+ * Group picture payload. Mirrors SetProfilePictureDto: provide exactly one of `url` or `base64`+ * (base64 wins when both are present), and a `mimetype` when using base64.+ */+export class SetGroupPictureDto {+ @ApiPropertyOptional({ description: 'Image URL (http/https)', example: 'https://example.com/group.jpg' })+ @IsOptional()+ @IsUrl()+ @ValidateIf((o: SetGroupPictureDto) => !o.base64)+ url?: string;++ @ApiPropertyOptional({ description: 'Base64 encoded image data' })+ @IsOptional()+ @IsString()+ @ValidateIf((o: SetGroupPictureDto) => !o.url)+ base64?: string;++ @ApiPropertyOptional({ description: 'Image MIME type (required when using base64)', example: 'image/jpeg' })+ @IsOptional()+ @IsString()+ // A group picture is an image by definition — reject non-image mimetypes fast (400) rather than+ // letting the engine accept an arbitrary payload.+ @Matches(/^image\//)+ mimetype?: string;+}+export class GroupSettingsDto {@ApiPropertyOptional({ description: 'Only admins can send messages (announce group)' })@ToStrictBoolean()diff --git a/src/modules/group/group.controller.ts b/src/modules/group/group.controller.tsindex cb8b511b1..36323cbcb 100644--- a/src/modules/group/group.controller.ts+++ b/src/modules/group/group.controller.ts@@ -8,6 +8,7 @@ import {GroupDescriptionDto,JoinGroupDto,GroupSettingsDto,+ SetGroupPictureDto,} from './dto/group.dto';import { RequireRole } from '../auth/decorators/auth.decorators';import { ApiKeyRole } from '../auth/entities/api-key.entity';@@ -213,6 +214,46 @@ export class GroupController {// ========== Gap Quick Wins: Invite Link ==========+ @Get(':groupId/picture')+ @ApiOperation({ summary: "Get the group's picture URL" })+ @ApiParam({ name: 'sessionId', description: 'Session ID' })+ @ApiParam({ name: 'groupId', description: 'Group ID' })+ @ApiResponse({ status: 200, description: 'Picture URL, or null when the group has none' })+ async getPicture(@Param('sessionId') sessionId: string, @Param('groupId') groupId: string) {+ return { url: await this.groupService.getGroupPicture(sessionId, groupId) };+ }++ @Put(':groupId/picture')+ @RequireRole(ApiKeyRole.OPERATOR)+ @HttpCode(HttpStatus.OK)+ @ApiOperation({ summary: "Set the group's picture" })+ @ApiParam({ name: 'sessionId', description: 'Session ID' })+ @ApiParam({ name: 'groupId', description: 'Group ID' })+ @ApiResponse({ status: 200, description: 'Group picture updated' })+ @ApiResponse({ status: 400, description: 'Session not active, or neither url nor base64 supplied' })+ @ApiResponse({ status: 403, description: 'The engine refused the change — admin rights required' })+ async setPicture(+ @Param('sessionId') sessionId: string,+ @Param('groupId') groupId: string,+ @Body() dto: SetGroupPictureDto,+ ) {+ await this.groupService.setGroupPicture(sessionId, groupId, dto);+ return { success: true, message: 'Group picture updated' };+ }++ @Delete(':groupId/picture')+ @RequireRole(ApiKeyRole.OPERATOR)+ @HttpCode(HttpStatus.OK)+ @ApiOperation({ summary: "Remove the group's picture" })+ @ApiParam({ name: 'sessionId', description: 'Session ID' })+ @ApiParam({ name: 'groupId', description: 'Group ID' })+ @ApiResponse({ status: 200, description: 'Group picture removed' })+ @ApiResponse({ status: 403, description: 'The engine refused the change — admin rights required' })+ async deletePicture(@Param('sessionId') sessionId: string, @Param('groupId') groupId: string) {+ await this.groupService.deleteGroupPicture(sessionId, groupId);+ return { success: true, message: 'Group picture removed' };+ }+@Get(':groupId/invite-code')@ApiOperation({ summary: 'Get group invite code/link' })@ApiParam({ name: 'sessionId', description: 'Session ID' })diff --git a/src/modules/group/group.service.ts b/src/modules/group/group.service.tsindex ff1a1dce9..8b94f3beb 100644--- a/src/modules/group/group.service.ts+++ b/src/modules/group/group.service.ts@@ -1,6 +1,8 @@import { Injectable, BadRequestException, HttpException, HttpStatus, NotFoundException } from '@nestjs/common';import { EngineRegistry } from '../../engine/engine-registry.service';-import { GroupMemberAddMode, IWhatsAppEngine } from '../../engine/interfaces/whatsapp-engine.interface';+import { GroupMemberAddMode, IWhatsAppEngine, MediaInput } from '../../engine/interfaces/whatsapp-engine.interface';+import { assertBase64WithinMediaCap, stripBase64DataUri } from '../message/media-cap.util';+import { SetGroupPictureDto } from './dto/group.dto';import { paginate, ListOptions } from '../../common/utils/paginate';/**@@ -77,6 +79,32 @@ export class GroupService {return this.getEngine(sessionId).joinGroupViaInviteCode(inviteCode);}+ /** Read the group's picture URL, or null when it has none. Groups reuse the profile-picture read. */+ getGroupPicture(sessionId: string, groupId: string): Promise<string | null> {+ return this.getEngine(sessionId).getProfilePicture(groupId);+ }++ setGroupPicture(sessionId: string, groupId: string, dto: SetGroupPictureDto): Promise<void> {+ const base64 = stripBase64DataUri(dto.base64);+ if (!dto.url && !base64) {+ throw new BadRequestException('Either url or base64 must be provided');+ }+ if (base64 && !dto.mimetype) {+ throw new BadRequestException('mimetype is required when using base64 data');+ }+ assertBase64WithinMediaCap(base64);+ const media: MediaInput = {+ mimetype: dto.mimetype || 'image/jpeg',+ // base64 wins over url when both are present, mirroring setProfilePicture.+ data: base64 || dto.url!,+ };+ return this.getEngine(sessionId).setGroupPicture(groupId, media);+ }++ deleteGroupPicture(sessionId: string, groupId: string): Promise<void> {+ return this.getEngine(sessionId).deleteGroupPicture(groupId);+ }+/** Read the group's announce/locked/ephemeral/member-add settings; 404s (via getGroupInfo) when unknown. */async getGroupSettings(sessionId: string, groupId: string) {const group = await this.getGroupInfo(sessionId, groupId);