-
-
Notifications
You must be signed in to change notification settings - Fork 880
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration issue.
- This issue is not already reported on Github (I've searched it).
Bug description
Hello,
in the 2.7 release placeholders has changed, as written in the changelog
EventManager: Placeholder names must now use the format {{.VirtualPath}} (previously {{VirtualPath}}). Existing placeholders are automatically converted during update.
I created an event that triggers an action after a new user is created.
The action make an HTTP Post with a json in the body, like this:
{"src_username":"{{.ObjectName}}","dst_username":"{{.ObjectName}}","ObjectData":{{.ObjectData}}}
"Content-Type" and "accept" headers are both "application/json"
The payload in the HTTP request contains an empty object on ObjectData
{"src_username":"test1","dst_username":"test1","ObjectData":{}}
Tried to use "the old way" with "{{ObjectData}}" with no success, the payload contains
{"src_username":"test1","dst_username":"test1","ObjectData":{{ObjectData}}}
After some tests i figured out that to send "{{.ObjectData}}" values the old placeholder "{{ObjectData}}" has to be present inside the body payload. The below link could be useful
HasObjectData Function
If I put an object of this type in the body, the result is what I expect.
HTTP Body inside the Action:
{"src_username":"{{.ObjectName}}","dst_username":"{{.ObjectName}}","ObjectData":{{.ObjectData}},"ObjectDataUseless":"{{ObjectData}}"}
HTTP Payload sents:
{ "src_username": "yyy", "dst_username": "yyy", "ObjectDataUseless": "{{ObjectData}}", "ObjectData": { "id": 16, "status": 1, "username": "yyy", "has_password": true, "home_dir": "\/srv\/sftpgo\/data\/yyy" .... } }
Steps to reproduce
1.Create new rule for a new user added
2.Create an HTTP action and set inside the body {"SomeFieldName":"{{.ObjectName}}","ObjectData":{{.ObjectData}}}
3.Intercept the request and check body payload
Expected behavior
.
SFTPGo version
2.7
Data provider
SQLite
Installation method
Community Deb package
Configuration
config
Relevant log output
What are you using SFTPGo for?
Private user, home usecase (home backup/VPS)
Additional info
No response