@@ -26,6 +26,35 @@ ActionService.Reporter = Console.new(`{script.Name}`)
26
26
27
27
ActionService .Actions = {}
28
28
29
+ function ActionService .ParseArgument (self : ActionService , argumentData : any , serverArgumentData : any )
30
+ if serverArgumentData .array then
31
+ local arrayObject = {}
32
+ local jsonDecoded = HttpService :JSONDecode (serverArgumentData .value )
33
+
34
+ for _ , value in jsonDecoded do
35
+ -- fixme: this is not nice, look into cleaning this code
36
+
37
+ table.insert (arrayObject , self :ParseArgument ({
38
+ Type = argumentData .Type
39
+ }, {
40
+ value = value
41
+ }))
42
+ end
43
+ end
44
+
45
+ if
46
+ argumentData .Type == ArgumentType .String
47
+ or argumentData .Type == ArgumentType .Number
48
+ or argumentData .Type == ArgumentType .Boolean
49
+ then
50
+ return serverArgumentData .value
51
+ elseif argumentData .Type == ArgumentType .Player then
52
+ return Players :GetPlayerByUserId (serverArgumentData .value )
53
+ end
54
+
55
+ return
56
+ end
57
+
29
58
function ActionService .RegisterActionAsync (self : ActionService , action : any )
30
59
local requestBody = {}
31
60
@@ -44,6 +73,7 @@ function ActionService.RegisterActionAsync(self: ActionService, action: any)
44
73
argumentBody .description = argumentObject .Description
45
74
argumentBody .required = argumentObject .Required
46
75
argumentBody .default = argumentObject .Default
76
+ argumentBody .array = argumentObject .IsArray
47
77
argumentBody .type = string.upper (argumentObject .Type )
48
78
49
79
table.insert (requestBody .arguments , argumentBody )
@@ -135,16 +165,14 @@ function ActionService.OnStart(self: ActionService)
135
165
return
136
166
end
137
167
138
- if
139
- argumentData .Type == ArgumentType .String
140
- or argumentData .Type == ArgumentType .Number
141
- or argumentData .Type == ArgumentType .Boolean
142
- then
143
- argumentValue = serverArgumentData .value
144
- elseif argumentData .Type == ArgumentType .Player then
145
- argumentValue = Players :GetPlayerByUserId (serverArgumentData .value )
168
+ if serverArgumentData .array ~= argumentData .IsArray then
169
+ self .Reporter :Warn (`Argument '{argumentName }' has invalid types! Dropping Action request!` )
170
+
171
+ return
146
172
end
147
173
174
+ argumentValue = self :ParseArgument (argumentData , serverArgumentData )
175
+
148
176
table.insert (sanitizedArguments , argumentValue )
149
177
else
150
178
if argumentData .Required then
0 commit comments