mirror of
https://github.com/appleboy/drone-discord.git
synced 2026-06-04 18:33:47 +08:00
feat: filter out empty messages in configuration processing
- Add a check for empty messages in the configuration - Replace the original message handling with a filtered list of non-empty messages - Update the logic to process messages only if the filtered list is not empty Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
@@ -214,7 +214,16 @@ func (p *Plugin) Exec(ctx context.Context) error {
|
||||
return fmt.Errorf("failed to validate config: %w", err)
|
||||
}
|
||||
|
||||
if len(p.Config.Message) == 0 {
|
||||
// check if message is empty
|
||||
messages := []string{}
|
||||
for _, m := range p.Config.Message {
|
||||
if m == "" {
|
||||
continue
|
||||
}
|
||||
messages = append(messages, m)
|
||||
}
|
||||
|
||||
if len(messages) == 0 {
|
||||
object := p.Template()
|
||||
p.Payload.Embeds = []EmbedObject{object}
|
||||
err := p.SendMessage(ctx)
|
||||
@@ -223,8 +232,8 @@ func (p *Plugin) Exec(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
if len(p.Config.Message) > 0 {
|
||||
for _, m := range p.Config.Message {
|
||||
if len(messages) > 0 {
|
||||
for _, m := range messages {
|
||||
txt, err := templateMessage(m, *p)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user