| CRMConfig = EspoCRMAPIConfig{ | CRMConfig = EspoCRMAPIConfig{ | ||||
| "https://c.hitxy.org.au/", | "https://c.hitxy.org.au/", | ||||
| "wechat", | "wechat", | ||||
| "crmwechat.api"} | |||||
| GlobalPath = PathsConfig{"/tmp", "/tmp"} | |||||
| "crmwechat.api", | |||||
| "/tmp/"} | |||||
| GlobalPath = PathsConfig{"/tmp"} | |||||
| KFUsers.kfRenewList() | KFUsers.kfRenewList() | ||||
| } | } | ||||
| //access Password | //access Password | ||||
| UserPass string `json:"UserPass"` | UserPass string `json:"UserPass"` | ||||
| AttachmentCache string `json:"AttachmentCache"` | |||||
| } | } | ||||
| //CRMConfig contains secrets that cannot store in source file | //CRMConfig contains secrets that cannot store in source file |
| { | { | ||||
| "BaseURL": "https://crm.hitxy.org.au/", | "BaseURL": "https://crm.hitxy.org.au/", | ||||
| "UserName": "wechat", | "UserName": "wechat", | ||||
| "UserPass": "crmwechat.api" | |||||
| "UserPass": "crmwechat.api", | |||||
| "AttachmentCache" : "/tmp/" | |||||
| } | } |
| //PathsConfig all system available pathes | //PathsConfig all system available pathes | ||||
| type PathsConfig struct { | type PathsConfig struct { | ||||
| CRMAttachment string `json:"crm_attachment"` | |||||
| Angular2App string `json:"angular2_app"` | |||||
| Angular2App string `json:"angular2_app"` | |||||
| } | } | ||||
| //TODO: setup GlobalPath Config, from reading file | //TODO: setup GlobalPath Config, from reading file | ||||
| //GlobalPath all global pathes configurations | //GlobalPath all global pathes configurations | ||||
| var GlobalPath = PathsConfig{ | var GlobalPath = PathsConfig{ | ||||
| "/tmp/", | |||||
| "/mnt/data/workspace/angular.ts/wechat/ng2-admin/dist/"} | "/mnt/data/workspace/angular.ts/wechat/ng2-admin/dist/"} | ||||
| //KFUsers info cache about current customer service | //KFUsers info cache about current customer service |
| //in this way, user has no 'direct-access' to the CRM server. | //in this way, user has no 'direct-access' to the CRM server. | ||||
| func crmAttachmentHandler(w http.ResponseWriter, r *http.Request) { | func crmAttachmentHandler(w http.ResponseWriter, r *http.Request) { | ||||
| fileID := getCrmFileID(r.URL.Path) | fileID := getCrmFileID(r.URL.Path) | ||||
| saveAs := GlobalPath.CRMAttachment + "crm_attach_" + fileID //add prefix for easy deleting | |||||
| saveAs := CRMConfig.AttachmentCache + "crm_attach_" + fileID //add prefix for easy deleting | |||||
| if isFileExist(saveAs) { | if isFileExist(saveAs) { | ||||
| http.ServeFile(w, r, saveAs) | http.ServeFile(w, r, saveAs) | ||||
| return | return |