@@ -4,15 +4,17 @@ import (
44 "encoding/json"
55 "os"
66
7+ middlewares "github.com/codeshelldev/secured-signal-api/internals/proxy/middlewares"
78 log "github.com/codeshelldev/secured-signal-api/utils/logger"
89)
910
1011type ENV_ struct {
11- PORT string
12- API_URL string
13- API_TOKEN string
14- BLOCKED_ENDPOINTS []string
15- VARIABLES map [string ]any
12+ PORT string
13+ API_URL string
14+ API_TOKEN string
15+ BLOCKED_ENDPOINTS []string
16+ VARIABLES map [string ]any
17+ MESSAGE_ALIASES []middlewares.MessageAlias
1618}
1719
1820var ENV ENV_ = ENV_ {
@@ -30,6 +32,44 @@ var ENV ENV_ = ENV_{
3032 "RECIPIENTS" : []string {},
3133 "NUMBER" : os .Getenv ("SENDER" ),
3234 },
35+ MESSAGE_ALIASES : []middlewares.MessageAlias {
36+ {
37+ Alias : "msg" ,
38+ Priority : 100 ,
39+ },
40+ {
41+ Alias : "content" ,
42+ Priority : 99 ,
43+ },
44+ {
45+ Alias : "description" ,
46+ Priority : 98 ,
47+ },
48+ {
49+ Alias : "text" ,
50+ Priority : 20 ,
51+ },
52+ {
53+ Alias : "body" ,
54+ Priority : 15 ,
55+ },
56+ {
57+ Alias : "summary" ,
58+ Priority : 10 ,
59+ },
60+ {
61+ Alias : "details" ,
62+ Priority : 9 ,
63+ },
64+ {
65+ Alias : "payload" ,
66+ Priority : 2 ,
67+ },
68+ {
69+ Alias : "data" ,
70+ Priority : 1 ,
71+ },
72+ },
3373}
3474
3575func Load () {
@@ -40,6 +80,7 @@ func Load() {
4080
4181 blockedEndpointJSON := os .Getenv ("BLOCKED_ENDPOINTS" )
4282 recipientsJSON := os .Getenv ("DEFAULT_RECIPIENTS" )
83+ messageAliasesJSON := os .Getenv ("MESSAGE_ALIASES" )
4384 variablesJSON := os .Getenv ("VARIABLES" )
4485
4586 log .Info ("Loaded Environment Variables" )
@@ -64,6 +105,18 @@ func Load() {
64105 ENV .BLOCKED_ENDPOINTS = blockedEndpoints
65106 }
66107
108+ if messageAliasesJSON != "" {
109+ var msgAliases []middlewares.MessageAlias
110+
111+ err := json .Unmarshal ([]byte (messageAliasesJSON ), & msgAliases )
112+
113+ if err != nil {
114+ log .Error ("Could not decode Message Aliases " , variablesJSON )
115+ }
116+
117+ ENV .MESSAGE_ALIASES = msgAliases
118+ }
119+
67120 if variablesJSON != "" {
68121 var variables map [string ]interface {}
69122
0 commit comments