Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/wecom #214

Closed
wants to merge 9 commits into from
28 changes: 28 additions & 0 deletions docs/config/handbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,29 @@ export default [
},
],
},
{
title: 'Synchronize',
'title.zh-CN': '同步',
children: [
{
title: 'Overview',
'title.zh-CN': '概述',
link: '/handbook/user-data-sync',
},
{
title: 'User manual',
'title.zh-CN': '使用手册',
link: '/handbook/user-data-sync/manual',
},
{
title: 'Development',
'title.zh-CN': '开发指南',
children: [
'/handbook/user-data-sync/dev/guide',
],
},
],
}
],
},
{
Expand Down Expand Up @@ -1530,6 +1553,11 @@ export default [
'title.ja-JP': '通知:メール',
link: '/handbook/notification-email',
},
{
title: 'Notification: WeCom',
'title.zh-CN': '通知:企业微信',
link: '/handbook/notification-wecom',
},
],
},
{
Expand Down
20 changes: 19 additions & 1 deletion docs/en-US/handbook/auth-wecom/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ Click on "Add new" and select "WeCom" from the list.

### Configuration Steps

![](https://static-docs.nocobase.com/202406272116978.png)
![](./static/screenshot-wecom-config1.png)

![](./static/screenshot-wecom-config2.png)

- When a phone number does not match an existing user, should a new user be created automatically - When the phone number does not match an existing user, a new user is automatically created.
- "Company ID, "AgentId" And "Secret" - Enter the key information copied in the previous step.
- Automatic login - After enabling this option, open the application links in the WeCom chat dialog will automatically log in, and the application links can also be configured on the home page of the workbench application, and only one WeCom authenticator can enable this option.
- Workbench application homepage link - Enter the Workbench application homepage link, then copy and proceed to the next step.

## Configuring the WeCom Application Homepage
Expand All @@ -78,6 +81,21 @@ In the WeCom admin console, paste the previously copied Workbench application ho

![](https://static-docs.nocobase.com/202406272123048.png)

## Configure the home page of the WeCom mobile client.

### Method one

Open the WeCom login configuration, set the Workbench app redirect link to the mobile page path, and copy the Workbench app home page link, then configure this link into the WeCom app.

![](./static/screenshot-wecom-config3.png)

### Method two

Open the WeCom login configuration, enable automatic login, and configure the system's mobile link within the WeCom app.

![](./static/screenshot-wecom-config4.png)
![](./static/screenshot-wecom-config5.png)

## Logging In

To log in, visit the NocoBase login page and click the button below the login form to start the third-party authentication process.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions docs/en-US/handbook/notification-wecom/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Notification: WeCom

<PluginInfo commercial="true" name="auth-wecom"></PluginInfo>

## Introduction

Send notifications through the WeCom channel.

## User Manual

### Install and enable the auth-wecom plugin, and configure wecom authentication

[auth: wecom](https://docs.nocobase.com/plugins/auth-wecom)

### WeCom channel configuration

![20241020112236](./static/20241020112236.png)

![](./static/screenshot-wecom-config6.png)

- Authenticator - Authenticator, Configured WeCom authenticator

### Workflow notification configuration

The WeCom channel currently supports three types of messages in workflow notifications: Text card message, Markdown message, and Template card message - Text notice. For details on each message type, please refer to [the documentation](https://developer.work.weixin.qq.com/document/path/90236).

#### Text card message

![](./static/screenshot-wecom-config9.png)

WeCom documentation:[Text card message](https://developer.work.weixin.qq.com/document/path/90236#%E6%96%87%E6%9C%AC%E5%8D%A1%E7%89%87%E6%B6%88%E6%81%AF)

#### Markdown message

![](./static/screenshot-wecom-config10.png)

WeCom documentation:[Markdown message](https://developer.work.weixin.qq.com/document/path/90236#markdown%E6%B6%88%E6%81%AF)

#### Template card message - text notice

Before using template card messages, you need to set up a message callback first.

Go to the WeCom application management backend and find the message reception configuration.

![](./static/screenshot-wecom-config11.png)

After entering the configuration page, generate the Token and EncodingAESKey.

![](./static/screenshot-wecom-config12.png)

Open the system and set up the synchronization of WeCom user data.

![](./static/screenshot-wecom-config13.png)

The basic configuration parameters should be consistent with the selected WeCom authentication configuration. Enter the Token and EncodingAESKey generated in the WeCom application backend, enable the settings, and submit to save. After saving, reopen the configuration information, copy the directory callback notification link, and paste it into the URL field of the message reception configuration in the Enterprise WeCom configuration, then save the message reception settings.

![](./static/screenshot-wecom-config14.png)

After completing the above steps, you can then configure the notifications.

![](./static/screenshot-wecom-config7.png)

![](./static/screenshot-wecom-config8.png)

WeCom documentation:[Template card message - text notice](https://developer.work.weixin.qq.com/document/path/90236#%E6%96%87%E6%9C%AC%E9%80%9A%E7%9F%A5%E5%9E%8B)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
145 changes: 145 additions & 0 deletions docs/en-US/handbook/user-data-sync/dev/guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Extend User Data Source Type

## Overview

NocoBase supports extending user data source types as needed.

## Server

### Interface

NocoBase provides registration and management for extending synchronization data source types. To extend the core logic processing, it is necessary to inherit the `SyncSource` abstract class provided by the plugin and implement the corresponding standard interfaces.

```ts
import { SyncSource, UserData } from '@nocobase/plugin-user-data-sync';

class CustomSyncSource extends SyncSource {
async pull(): Promise<UserData[]> {
return [];
}
}
```

The `SyncSource` provides an `options` property that is used to retrieve custom configurations for the data source.

```ts
import { SyncSource, UserData } from '@nocobase/plugin-user-data-sync';

class CustomSyncSource extends SyncSource {
async pull(): Promise<UserData[]> {
//...
const { appid, secret } = this.options;
//...
return [];
}
}
```

### Explanation of the UserData Field

| Field | Description |
| -------- | ---------------------- |
| `dataType` | Data type, with optional values of `user` and `department` |
| `uniqueKey` | Unique identifier field |
| `records` | Data record |
| `sourceName` | Source name |

If dataType is `user`, then records contain the following fields:

| Field | Description |
| -------- | ---------------------- |
| `id` | User ID |
| `nickname` | User nickname |
| `avatar` | User avatar |
| `email` | Email |
| `phone` | Phone number |
| `departments` | Array of Department IDs |

If dataType is `department`, then records contain the following fields:

| Field | Description |
| -------- | ---------------------- |
| `id` | Department ID |
| `name` | Department name |
| `parentId` | Parent department ID |

### Complete Example of Implementing the Interface

```ts
import { SyncSource, UserData } from '@nocobase/plugin-user-data-sync';

class CustomSyncSource extends SyncSource {
async pull(): Promise<UserData[]> {
// ...
const ThirdClientApi = new ThirdClientApi(this.options.appid, this.options.secret);
const departments = await this.clientapi.getDepartments();
const users = await this.clientapi.getUsers();
// ...
return [
{
dataType: 'department',
uniqueKey: 'id',
records: departments,
sourceName: this.instance.name,
},
{
dataType: 'user',
uniqueKey: 'id',
records: users,
sourceName: this.instance.name,
},
];
}
}
```

### Registration of Data Source Types

Extended data sources need to be registered with the data management module.

```ts
import UserDataSyncPlugin from '@nocobase/plugin-user-data-sync';

class CustomSourcePlugin extends Plugin {
async load() {
const syncPlugin = this.app.pm.get(UserDataSyncPlugin) as UserDataSyncPlugin;
if (syncPlugin) {
syncPlugin.sourceManager.reigsterType('custom-source-type', {
syncSource: CustomSyncSource,
title: 'Custom Source',
});
}
}
}
```

## Client

The client user interface is registered through the `registerType` interface provided by the user data synchronization plugin client.

```ts
import SyncPlugin from '@nocobase/plugin-user-data-sync/client';

class CustomSourcePlugin extends Plugin {
async load() {
const sync = this.app.pm.get(SyncPlugin);
sync.registerType(authType, {
components: {
AdminSettingsForm, // Backend management form
},
});
}
}
```

### Backend Management Form

![](./static/20240813135430.png)

The upper part is the general data source configuration, and the lower part is the customizable configuration form section that can be registered.

## Data Push From Third-party Systems

Third-party systems can also push data to Nocobase through the Nocobase HTTP API to achieve user data synchronization.

For detailed API documentation, please visit the API documentation page: http://localhost:13000/admin/settings/api-doc/documentation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions docs/en-US/handbook/user-data-sync/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# User Data Synchronization

<PluginInfo name="user-data-sync"></PluginInfo>

## Introduction

Provide user data source management, user data synchronization interfaces, with data sources including DingTalk, WeCom, and others, which are also extensible. Currently, it can synchronize `user` and `department` data.

## Installation

Built-in plugin, no separate installation required.
40 changes: 40 additions & 0 deletions docs/en-US/handbook/user-data-sync/manual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# User Guide

## User Data Source Management

The user data synchronization plugin provides a management interface in the configuration center.

![](./static/20240813134409.png)

## Activate User Data Source

Only activated data sources will display the sync and task buttons.

![](./static/20240813134707.png)

## Synchronize User Data

After clicking the sync button, synchronization will start immediately.

![](./static/20240813134818.png)

After clicking the task button, you can view the list of synchronization tasks.

![](./static/20240813135105.png)

![](./static/20240813134110.png)

In the task list, you can retry failed tasks by clicking on them to restart synchronization.

![](./static/20240813134933.png)

## User Data Source Type

![](./static/20240813133944.png)

Currently supported data source types include:

- DingTalk, expanded by [dingtalk-auth plugin](../auth-dingtalk/index.md)
- WeCom, expanded by [wecom-auth plugin](../auth-wecom/index.md)

In addition, you can also expand user data source by yourself, refer to the [Developer's Guide](./dev/guide.md).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 23 additions & 3 deletions docs/zh-CN/handbook/auth-wecom/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,42 @@

![](https://static-docs.nocobase.com/202406272115805.png)

### 配置
## 配置

![](./static/screenshot-wecom-config1.png)

![](./static/screenshot-wecom-config2.png)

![](https://static-docs.nocobase.com/202406272116978.png)

- When a phone number does not match an existing user, should a new user be created automatically - 当使用手机号匹配不到已有用户时,是否自动创建新用户。
- Company ID, AgentId 和 Secret - 填写上一步复制的密钥信息。
- Origin - 当前应用的域名。
- Automatic login - 自动登录。启用此选项后,企微聊天对话框中打开系统链接会自动登录,同时工作台应用主页上可配置系统链接,只有一个企微认证器可开启该选项。
- Workbench application homepage link - 工作台应用主页链接,复制并进入下一步。

## 配置企业微信应用首页

进入企业微信管理员后台,将复制的工作台应用主页链接填写到对应应用的应用主页地址栏。
进入企业微信管理员后台,将复制的工作台应用主页链接填写到对应应用的应用主页地址栏。若开启的自动登录选项,则可以直接配置系统指定页面链接。

![](https://static-docs.nocobase.com/202406272123631.png)

![](https://static-docs.nocobase.com/202406272123048.png)

## 配置企业微信移动端首页

### 方法一

打开企微登录配置,将工作台应用跳转链接配置为移动端页面路径,并复制工作台应用主页链接,将该链接配置到企微应用

![](./static/screenshot-wecom-config3.png)

### 方法二

打开企微登录配置,启用自动登录,并且在企微应用中配置系统的移动端链接

![](./static/screenshot-wecom-config4.png)
![](./static/screenshot-wecom-config5.png)

## 登录

访问登录页面,点击登录表单下方按钮发起第三方登录。
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading