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

Create user center slack and integrate with importer #230

Merged
merged 7 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 13 additions & 13 deletions notification-slack/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Slack Notification
## Feature
- Send message to Slack

## Config
> Config Webhook URL and open the notification

- Webhook URL: such as `https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX`

## Preview
![Slack Config](./docs/slack-config.png)

## Document
# Slack Notification
## Feature
- Send message to Slack
## Config
> Config Webhook URL and open the notification
- Webhook URL: such as `https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX`
## Preview
![Slack Config](./docs/slack-config.png)
## Document
- https://api.slack.com/messaging/webhooks
106 changes: 53 additions & 53 deletions notification-slack/config.go
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package slack

import (
"encoding/json"

"github.com/apache/incubator-answer-plugins/notification-slack/i18n"
"github.com/apache/incubator-answer/plugin"
)

type NotificationConfig struct {
Notification bool `json:"notification"`
}

func (n *Notification) ConfigFields() []plugin.ConfigField {
return []plugin.ConfigField{
{
Name: "notification",
Type: plugin.ConfigTypeSwitch,
Title: plugin.MakeTranslator(i18n.ConfigNotificationTitle),
Description: plugin.MakeTranslator(i18n.ConfigNotificationDescription),
UIOptions: plugin.ConfigFieldUIOptions{
Label: plugin.MakeTranslator(i18n.ConfigNotificationLabel),
},
Value: n.Config.Notification,
},
}
}

func (n *Notification) ConfigReceiver(config []byte) error {
c := &NotificationConfig{}
_ = json.Unmarshal(config, c)
n.Config = c
return nil
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package slack_notification
import (
"encoding/json"
"github.com/Anan1225/incubator-answer-plugins/notification-slack/i18n"
"github.com/apache/incubator-answer/plugin"
)
type NotificationConfig struct {
Notification bool `json:"notification"`
}
func (n *Notification) ConfigFields() []plugin.ConfigField {
return []plugin.ConfigField{
{
Name: "notification",
Type: plugin.ConfigTypeSwitch,
Title: plugin.MakeTranslator(i18n.ConfigNotificationTitle),
Description: plugin.MakeTranslator(i18n.ConfigNotificationDescription),
UIOptions: plugin.ConfigFieldUIOptions{
Label: plugin.MakeTranslator(i18n.ConfigNotificationLabel),
},
Value: n.Config.Notification,
},
}
}
func (n *Notification) ConfigReceiver(config []byte) error {
c := &NotificationConfig{}
_ = json.Unmarshal(config, c)
n.Config = c
return nil
}
98 changes: 50 additions & 48 deletions notification-slack/go.mod
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
module github.com/apache/incubator-answer-plugins/notification-slack

go 1.19

require (
github.com/apache/incubator-answer v1.3.6
github.com/apache/incubator-answer-plugins/util v1.0.2
github.com/go-resty/resty/v2 v2.11.0
github.com/segmentfault/pacman v1.0.5-0.20230822083413-c0075a2d401f
)

require (
github.com/LinkinStars/go-i18n/v2 v2.2.2 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.9.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/wire v0.5.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/segmentfault/pacman/contrib/i18n v0.0.0-20230516093754-b76aef1c1150 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
module github.com/Anan1225/incubator-answer-plugins/notification-slack

go 1.19

require (
github.com/apache/incubator-answer v1.3.6
github.com/apache/incubator-answer-plugins/util v1.0.2
github.com/go-resty/resty/v2 v2.15.0
github.com/segmentfault/pacman v1.0.5-0.20230822083413-c0075a2d401f
)

require (
github.com/LinkinStars/go-i18n/v2 v2.2.2 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.9.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/wire v0.5.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/segmentfault/pacman/contrib/i18n v0.0.0-20230516093754-b76aef1c1150 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/Anan1225/incubator-answer-plugins/notification-slack => /root/incubator-answer-plugins/notification-slack
Loading