Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Add channels.setCustomFields and groups.setCustomFields. Fix purpose. #600

Merged
merged 6 commits into from
May 28, 2018
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions _data/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
- removeModerator
- removeOwner
- rename
- setCustomFields
- setDescription
- setJoinCode
- setPurpose
Expand Down Expand Up @@ -260,6 +261,7 @@
- removeModerator
- removeOwner
- rename
- setCustomFields
- setDescription
- setPurpose
- setReadOnly
Expand Down
2 changes: 2 additions & 0 deletions contributing/documentation/documentation-map/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ Here you can also find what articles are incomplete and missing.
- removeModerator
- removeOwner
- rename
- setCustomFields
- setDescription
- setJoinCode
- setPurpose
Expand Down Expand Up @@ -306,6 +307,7 @@ Here you can also find what articles are incomplete and missing.
- removeModerator
- removeOwner
- rename
- setCustomFields
- setDescription
- setPurpose
- setReadOnly
Expand Down
40 changes: 21 additions & 19 deletions developer-guides/rest-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ When calling a production Rocket.Chat server, ensure it is running via HTTPS and
| `/api/v1/channels.list.joined` | Gets only the channels the calling user has joined. | [Link](channels/list-joined/) |
| `/api/v1/channels.open` | Adds the channel back to the user's list of channels. | [Link](channels/open/) |
| `/api/v1/channels.rename` | Changes a channel's name. | [Link](channels/rename/) |
| `/api/v1/channels.setCustomFields` | Sets a channel's custom fields. | [Link](channels/setcustomfields/) |
| `/api/v1/channels.setDescription` | Sets a channel's description. | [Link](channels/setdescription/) |
| `/api/v1/channels.setJoinCode` | Sets the channel's code required to join it. | [Link](channels/setjoincode/) |
| `/api/v1/channels.setPurpose` | Sets a channel's description. | [Link](channels/setpurpose/) |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please let this be as it was before, the api is called set purpose due compatibility reasons, it does really change the description of the channel (as shown in the ui)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. Restored with an obsolescence notification.

Expand All @@ -75,25 +76,26 @@ When calling a production Rocket.Chat server, ensure it is running via HTTPS and

### Groups

| Url | Short Description | Details Page |
| :------------------------------ | :------------------------------------------------- | :----------------------------- |
| `/api/v1/groups.archive` | Archives a private group. | [Link](groups/archive/) |
| `/api/v1/groups.close` | Removes a private group from the list of groups. | [Link](groups/close/) |
| `/api/v1/groups.create` | Creates a new private group. | [Link](groups/create/) |
| `/api/v1/groups.history` | Retrieves the messages from a private group. | [Link](groups/history/) |
| `/api/v1/groups.info` | Gets the information about a private group. | [Link](groups/info/) |
| `/api/v1/groups.invite` | Adds a user to the private group. | [Link](groups/invite/) |
| `/api/v1/groups.kick` | Removes a user from a private group. | [Link](groups/kick/) |
| `/api/v1/groups.leave` | Removes the calling user from the private group. | [Link](groups/leave/) |
| `/api/v1/groups.list` | List the private groups the caller is part of. | [Link](groups/list/) |
| `/api/v1/groups.open` | Adds the private group back to the list of groups. | [Link](groups/open/) |
| `/api/v1/groups.rename` | Changes the name of the private group. | [Link](groups/rename/) |
| `/api/v1/groups.setDescription` | Sets a private group's description. | [Link](groups/setdescription/) |
| `/api/v1/groups.setPurpose` | Sets a private group's description. | [Link](groups/setpurpose/) |
| `/api/v1/groups.setReadOnly` | Sets whether the room is read only or not. | [Link](groups/setreadonly/) |
| `/api/v1/groups.setTopic` | Sets a private group's topic. | [Link](groups/settopic/) |
| `/api/v1/groups.setType` | Sets the type of room this group will be. | [Link](groups/settype/) |
| `/api/v1/groups.unarchive` | Unarchives a private group. | [Link](groups/unarchive/) |
| Url | Short Description | Details Page |
| :------------------------------- | :------------------------------------------------- | :------------------------------ |
| `/api/v1/groups.archive` | Archives a private group. | [Link](groups/archive/) |
| `/api/v1/groups.close` | Removes a private group from the list of groups. | [Link](groups/close/) |
| `/api/v1/groups.create` | Creates a new private group. | [Link](groups/create/) |
| `/api/v1/groups.history` | Retrieves the messages from a private group. | [Link](groups/history/) |
| `/api/v1/groups.info` | Gets the information about a private group. | [Link](groups/info/) |
| `/api/v1/groups.invite` | Adds a user to the private group. | [Link](groups/invite/) |
| `/api/v1/groups.kick` | Removes a user from a private group. | [Link](groups/kick/) |
| `/api/v1/groups.leave` | Removes the calling user from the private group. | [Link](groups/leave/) |
| `/api/v1/groups.list` | List the private groups the caller is part of. | [Link](groups/list/) |
| `/api/v1/groups.open` | Adds the private group back to the list of groups. | [Link](groups/open/) |
| `/api/v1/groups.rename` | Changes the name of the private group. | [Link](groups/rename/) |
| `/api/v1/groups.setCustomFields` | Sets private group's custom fields. | [Link](groups/setcustomfields/) |
| `/api/v1/groups.setDescription` | Sets a private group's description. | [Link](groups/setdescription/) |
| `/api/v1/groups.setPurpose` | Sets a private group's description. | [Link](groups/setpurpose/) |
| `/api/v1/groups.setReadOnly` | Sets whether the room is read only or not. | [Link](groups/setreadonly/) |
| `/api/v1/groups.setTopic` | Sets a private group's topic. | [Link](groups/settopic/) |
| `/api/v1/groups.setType` | Sets the type of room this group will be. | [Link](groups/settype/) |
| `/api/v1/groups.unarchive` | Unarchives a private group. | [Link](groups/unarchive/) |

### Chat

Expand Down
1 change: 1 addition & 0 deletions developer-guides/rest-api/channels/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
| `/api/v1/channels.removeModerator` | Removes the role of moderator from a user in a channel. | [Link](removemoderator/) |
| `/api/v1/channels.removeOwner` | Removes the role of owner from a user in a channel. | [Link](removeowner/) |
| `/api/v1/channels.rename` | Changes a channel's name. | [Link](rename/) |
| `/api/v1/channels.setCustomFields` | Sets a channel's custom fields. | [Link](setcustomfields/) |
| `/api/v1/channels.setDescription` | Sets a channel's description. | [Link](setdescription/) |
| `/api/v1/channels.setJoinCode` | Sets the channel's code required to join it. | [Link](setjoincode/) |
| `/api/v1/channels.setPurpose` | Sets a channel's description. | [Link](setpurpose/) |
Expand Down
55 changes: 55 additions & 0 deletions developer-guides/rest-api/channels/setcustomfields/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Channel Set Custom Fields

Sets the custom fields for the channel.

| URL | Requires Auth | HTTP Method |
| :--- | :--- | :--- |
| `/api/v1/channels.setCustomFields` | `yes` | `POST` |

## Payload

One of roomId or roomName is required.

| Argument | Example | Required | Description |
| :--- | :--- | :--- | :--- |
| `roomId` | `GENERAL` | Required | The channel's id |
| `roomName` | `general` | Required | The channel's name |
| `customFields` | `{"organization": "tra-la-la"}` | Required | The custom fields to set for the channel. |

## Example Call

```bash
curl -H "X-Auth-Token: 8h2mKAwxB3AQrFSjLVKMooJyjdCFaA7W45sWlHP8IzO" \
-H "X-User-Id: ew28FnZqipDpvKw3R" \
-H "Content-type: application/json" \
http://localhost:3000/api/v1/channels.setCustomFields \
-d '{"roomId": "GENERAL", "customFields":{"organization": "tra-la-la"} }'
```

## Example Result

```json
{
"channel":{
"_id":"GENERAL",
"ts":"2018-02-18T19:41:02.875Z",
"t":"c",
"name":"general",
"msgs":236,
"default":true,
"_updatedAt":"2018-02-23T11:09:05.973Z",
"lm":"2018-02-18T22:18:20.288Z",
"customFields":{
"organization":"tra-la-la"
}
},
"success":true,
"developerWarning":"[WARNING]: The \"usernames\" field has been removed for performance reasons. Please use the \"*.members\" endpoint to get a list of members/users in a room."
}
```

## Change Log

| Version | Description |
| :--- | :--- |
| 0.62.0 | Added |
2 changes: 1 addition & 1 deletion developer-guides/rest-api/channels/setpurpose/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Channel Set Purpose

Sets the description for the channel.
Sets the description for the channel (the same as channels.setDescription, obsolete).

| URL | Requires Auth | HTTP Method |
| :--- | :--- | :--- |
Expand Down
1 change: 1 addition & 0 deletions developer-guides/rest-api/groups/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
| `/api/v1/groups.removeModerator` | Removes the role of moderator from a user in a group. | [Link](removemoderator/) |
| `/api/v1/groups.removeOwner` | Removes the role of owner from a user in a group. | [Link](removeowner/) |
| `/api/v1/groups.rename` | Changes the name of the private group. | [Link](rename/) |
| `/api/v1/groups.setCustomFields` | Sets private group's custom fields. | [Link](setcustomfields/) |
| `/api/v1/groups.setDescription` | Sets a private group's description. | [Link](setdescription/) |
| `/api/v1/groups.setPurpose` | Sets a private group's description. | [Link](setpurpose/) |
| `/api/v1/groups.setReadOnly` | Sets whether the room is read only or not. | [Link](setreadonly/) |
Expand Down
61 changes: 61 additions & 0 deletions developer-guides/rest-api/groups/setcustomfields/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Group Set Custom Fields

Sets the custom fields for the private group.

| URL | Requires Auth | HTTP Method |
| :--- | :--- | :--- |
| `/api/v1/groups.setCustomFields` | `yes` | `POST` |

## Payload

One of roomId or roomName is required.

| Argument | Example | Required | Description |
| :--- | :--- | :--- | :--- |
| `roomId` | `euzoT67Gx6nXcn66M` | Required | The private group's id |
| `roomName` | `channel.cf.1518990680083` | Required | The private group's name |
| `customFields` | `{"company": "sell-and-more"}` | Required | The custom fields to set for the private group. |

## Example Call

```bash
curl -H "X-Auth-Token: 8h2mKAwxB3AQrFSjLVKMooJyjdCFaA7W45sWlHP8IzO" \
-H "X-User-Id: ew28FnZqipDpvKw3R" \
-H "Content-type: application/json" \
http://localhost:3000/api/v1/groups.setCustomFields \
-d '{"roomId": "euzoT67Gx6nXcn66M", "customFields":{"company": "sell-and-more"} }'
```

## Example Result

```json
{
"group":{
"_id":"euzoT67Gx6nXcn66M",
"name":"channel.cf.1518990680083",
"fname":"channel.cf.1518990680083",
"t":"p",
"msgs":0,
"u":{
"_id":"ew28FnZqipDpvKw3R",
"username":"rocketchat.internal.admin.test"
},
"customFields":{
"company":"sell-and-more"
},
"ts":"2018-02-18T21:51:20.091Z",
"ro":false,
"sysMes":true,
"_updatedAt":"2018-02-23T11:27:01.411Z",
"username":"rocketchat.internal.admin.test"
},
"success":true,
"developerWarning":"[WARNING]: The \"usernames\" field has been removed for performance reasons. Please use the \"*.members\" endpoint to get a list of members/users in a room."
}
```

## Change Log

| Version | Description |
| :--- | :--- |
| 0.62.0 | Added |
2 changes: 1 addition & 1 deletion developer-guides/rest-api/groups/setpurpose/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Group Set Purpose

Sets the description for the private group.
Sets the description for the private group (the same as groups.setDescription, obsolete).

| URL | Requires Auth | HTTP Method |
| :--- | :--- | :--- |
Expand Down
89 changes: 56 additions & 33 deletions developer-guides/schema-definition/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,36 @@
"u": { // Object Owner User
"_id": "CABrXSHpDqbZXGkYR", // Random.id() User Id
"username": "john" // String User Username
},
"customFields": { // Object User defined custom fields (for t:c and t:p only)
"userDefinedField": "userValue", // User defined field example
"userDefinedField2": true, // User defined field example
"userObject3": { // User defined field example
"a": "hello",
"b": "lalala"
}
}
}
```

### Fields

| Fields | Type | Description |
| :---------- | :------------ | :----------------------- |
| \_id | Random.id() | Room Id |
| t | String | Room Type |
| ts | Date | Room Creation Timestamp |
| name | String | Room Name (t:d -> empty) |
| lm | Date | Last Message Timestamp |
| msgs | Integer | Messages Counter |
| cl | Boolean | If users can leave room |
| ro | Boolean | Read Only |
| usernames | Array[String] | Room Users |
| usernames.0 | String | User Username |
| u | Object | Owner User |
| u.\_id | Random.id() | User Id |
| u.username | String | User Username |
| Fields | Type | Description |
| :----------- | :------------ | :---------------------------------------- |
| \_id | Random.id() | Room Id |
| t | String | Room Type |
| ts | Date | Room Creation Timestamp |
| name | String | Room Name (t:d -> empty) |
| lm | Date | Last Message Timestamp |
| msgs | Integer | Messages Counter |
| cl | Boolean | If users can leave room |
| ro | Boolean | Read Only |
| usernames | Array[String] | Room Users |
| usernames.0 | String | User Username |
| u | Object | Owner User |
| u.\_id | Random.id() | User Id |
| u.username | String | User Username |
| customFields | Object | User custom fields (for t:c and t:p only) |

### Indexes

Expand Down Expand Up @@ -70,30 +79,44 @@
"v": { // Object Visitor
"_id": "CABrXSHpDqbZXGkYR", // Random.id() Visitor Id
"username": "anonymous" // String Visitor Username
},
"customFields": { // Object User defined custom fields
"userDefinedField": "userValue", // User defined field example
"userDefinedField2": true, // User defined field example
"userObject3": { // User defined field example
"a": "hello",
"b": "lalala"
}
}
}
```

### Fields

| Fields | Type | Description |
| :--------- | :---------- | :--------------------------------------------------------------- |
| \_id | Random.id() | Subscriptions Id |
| t | String | Subscription Type (copy from Room) |
| ts | Date | Subscription Creation Timestamp |
| ls | Date | Last Seen Timestamp |
| name | String | Subscription Name (t:d -> target username) |
| rid | Random.id() | Room Id |
| f | Boolean | Favorited |
| open | Boolean | Is Room Opened |
| alert | Boolean | Room has unread messages for this user |
| unread | Integer | Counter of unread messages with mentions or from direct messages |
| u | Object | User |
| u.\_id | Random.id() | User Id |
| u.username | String | User Username |
| v | Object | Visitor |
| v.\_id | Random.id() | Visitor Id |
| v.username | String | Visitor Username |
| Fields | Type | Description |
| :----------- | :---------- | :--------------------------------------------------------------- |
| \_id | Random.id() | Subscriptions Id |
| t | String | Subscription Type (copy from Room) |
| ts | Date | Subscription Creation Timestamp |
| ls | Date | Last Seen Timestamp |
| name | String | Subscription Name (t:d -> target username) |
| rid | Random.id() | Room Id |
| f | Boolean | Favorited |
| open | Boolean | Is Room Opened |
| alert | Boolean | Room has unread messages for this user |
| unread | Integer | Counter of unread messages with mentions or from direct messages |
| u | Object | User |
| u.\_id | Random.id() | User Id |
| u.username | String | User Username |
| v | Object | Visitor |
| v.\_id | Random.id() | Visitor Id |
| v.username | String | Visitor Username |
| customFields | Object | User custom fields |

Notes about customFields:

- customFields inherits from room's customFields for channels (Room Type: c = chanel) and groups (Room Type: p = group) and changes with room's customFields
- customFields inherits from user's customFields for Direct Messages (Room Type: d = direct) and changes with user's customFields. Note that users of Direct Messages room will have own customFields.

### Indexes

Expand Down