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

auto split webhook token when user input hook url #1262

Merged
merged 1 commit into from
Sep 25, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -274,23 +274,44 @@
'alert.notice.type.wework-key' | i18n
}}</nz-form-label>
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
<input [(ngModel)]="receiver.wechatId" nz-input [required]="receiver.type === 4" name="wechatId" type="text" />
<input
[(ngModel)]="receiver.wechatId"
(ngModelChange)="onSplitTokenStr(4)"
nz-input
[required]="receiver.type === 4"
name="wechatId"
type="text"
/>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="receiver.type === 5">
<nz-form-label [nzSpan]="7" nzFor="accessToken" [nzRequired]="receiver.type === 5">{{
'alert.notice.type.access-token' | i18n
}}</nz-form-label>
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
<input [(ngModel)]="receiver.accessToken" nz-input [required]="receiver.type === 5" name="accessToken" type="text" />
<input
[(ngModel)]="receiver.accessToken"
(ngModelChange)="onSplitTokenStr(5)"
nz-input
[required]="receiver.type === 5"
name="accessToken"
type="text"
/>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="receiver.type === 6">
<nz-form-label [nzSpan]="7" nzFor="wechatId" [nzRequired]="receiver.type === 6">{{
'alert.notice.type.fei-shu-key' | i18n
}}</nz-form-label>
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
<input [(ngModel)]="receiver.wechatId" nz-input [required]="receiver.type === 6" name="wechatId" type="text" />
<input
[(ngModel)]="receiver.wechatId"
(ngModelChange)="onSplitTokenStr(6)"
nz-input
[required]="receiver.type === 6"
name="wechatId"
type="text"
/>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="receiver.type === 7">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,36 @@ export class AlertNoticeComponent implements OnInit {
isSendTestButtonLoading: boolean = false;
receiver!: NoticeReceiver;

onSplitTokenStr(type: number) {
let index = -1;
switch (this.receiver?.type) {
case 4:
if (this.receiver?.wechatId) {
index = this.receiver.wechatId.indexOf('key=');
if (index > 0) {
this.receiver.wechatId = this.receiver.wechatId.substring(index + 4);
}
}
break;
case 5:
if (this.receiver?.accessToken) {
index = this.receiver.accessToken.indexOf('access_token=');
if (index > 0) {
this.receiver.accessToken = this.receiver.accessToken.substring(index + 13);
}
}
break;
case 6:
if (this.receiver?.wechatId) {
index = this.receiver.wechatId.indexOf('hook');
if (index > 0) {
this.receiver.wechatId = this.receiver.wechatId.substring(index + 5);
}
}
break;
}
}

onNewNoticeReceiver() {
this.receiver = new NoticeReceiver();
this.isManageReceiverModalVisible = true;
Expand Down
Loading