This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
2017-12-16 23:20:46 +01:00
|
|
|
package extension
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/xml"
|
|
|
|
|
2018-02-07 15:34:18 +01:00
|
|
|
"dev.sum7.eu/genofire/yaja/server/utils"
|
2017-12-16 23:20:46 +01:00
|
|
|
)
|
|
|
|
|
2017-12-17 13:31:02 +01:00
|
|
|
type Extensions []Extension
|
|
|
|
|
2017-12-16 23:20:46 +01:00
|
|
|
type Extension interface {
|
|
|
|
Process(*xml.StartElement, *utils.Client) bool
|
2017-12-17 13:31:02 +01:00
|
|
|
Spaces() []string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ex Extensions) Spaces() (result []string) {
|
|
|
|
for _, extension := range ex {
|
|
|
|
result = append(result, extension.Spaces()...)
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ex Extensions) Process(element *xml.StartElement, client *utils.Client) {
|
|
|
|
log := client.Log.WithField("extension", "all")
|
|
|
|
|
|
|
|
// run every extensions
|
|
|
|
count := 0
|
|
|
|
for _, extension := range ex {
|
|
|
|
if extension.Process(element, client) {
|
|
|
|
count++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// not extensions found
|
|
|
|
if count != 1 {
|
|
|
|
log.Debug(element)
|
|
|
|
}
|
2017-12-16 23:20:46 +01:00
|
|
|
}
|