Skip to content

Add check if rule name already exists in /autolink add command #212

@dmarushkin

Description

@dmarushkin

Thare are no checks if Name already exists in function executeAdd:

server/autolinkplugin/command.go:
`
func executeAdd(p *Plugin, c *plugin.Context, header *model.CommandArgs, args ...string) *model.CommandResponse {
if len(args) > 1 {
return responsef(helpText)
}
name := ""
if len(args) == 1 {
name = args[0]
}

err := saveConfigLinks(p, append(p.getConfig().Links, autolink.Autolink{
	Name: name,
}))
if err != nil {
	return responsef(err.Error())
}

if name == "" {
	return executeList(p, c, header)
}
return executeList(p, c, header, name)

}
`

After adding second rule with the same name we can't change prev or new rule or even delete new one. Instead we got this message:

"Visa" matched more than one link: ["Visa" "Visa"]

So we can fix that by checking name in existing rules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions