Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit 6684d2b

Browse files
committed
POST api payloads in the request body, not url
Even though some methods are specifically set to make POST requests, they still send the message payload entirely in params like a GET request. The max length of a url is much lower than the 16K bytes that Slack accepts in request bodies.
1 parent 364bbe8 commit 6684d2b

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

slacker/__init__.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def get_presence(self, user):
9494

9595
def set_presence(self, presence):
9696
assert presence in Presence.TYPES, 'Invalid presence type'
97-
return self.post('users.setPresence', params={'presence': presence})
97+
return self.post('users.setPresence', data={'presence': presence})
9898

9999
def get_user_id(self, user_name):
100100
members = self.list().body['members']
@@ -103,10 +103,10 @@ def get_user_id(self, user_name):
103103

104104
class Groups(BaseAPI):
105105
def create(self, name):
106-
return self.post('groups.create', params={'name': name})
106+
return self.post('groups.create', data={'name': name})
107107

108108
def create_child(self, channel):
109-
return self.post('groups.createChild', params={'channel': channel})
109+
return self.post('groups.createChild', data={'channel': channel})
110110

111111
def info(self, channel):
112112
return self.get('groups.info', params={'channel': channel})
@@ -128,46 +128,46 @@ def history(self, channel, latest=None, oldest=None, count=None,
128128

129129
def invite(self, channel, user):
130130
return self.post('groups.invite',
131-
params={'channel': channel, 'user': user})
131+
data={'channel': channel, 'user': user})
132132

133133
def kick(self, channel, user):
134134
return self.post('groups.kick',
135-
params={'channel': channel, 'user': user})
135+
data={'channel': channel, 'user': user})
136136

137137
def leave(self, channel):
138-
return self.post('groups.leave', params={'channel': channel})
138+
return self.post('groups.leave', data={'channel': channel})
139139

140140
def mark(self, channel, ts):
141-
return self.post('groups.mark', params={'channel': channel, 'ts': ts})
141+
return self.post('groups.mark', data={'channel': channel, 'ts': ts})
142142

143143
def rename(self, channel, name):
144144
return self.post('groups.rename',
145-
params={'channel': channel, 'name': name})
145+
data={'channel': channel, 'name': name})
146146

147147
def archive(self, channel):
148-
return self.post('groups.archive', params={'channel': channel})
148+
return self.post('groups.archive', data={'channel': channel})
149149

150150
def unarchive(self, channel):
151-
return self.post('groups.unarchive', params={'channel': channel})
151+
return self.post('groups.unarchive', data={'channel': channel})
152152

153153
def open(self, channel):
154-
return self.post('groups.open', params={'channel': channel})
154+
return self.post('groups.open', data={'channel': channel})
155155

156156
def close(self, channel):
157-
return self.post('groups.close', params={'channel': channel})
157+
return self.post('groups.close', data={'channel': channel})
158158

159159
def set_purpose(self, channel, purpose):
160160
return self.post('groups.setPurpose',
161-
params={'channel': channel, 'purpose': purpose})
161+
data={'channel': channel, 'purpose': purpose})
162162

163163
def set_topic(self, channel, topic):
164164
return self.post('groups.setTopic',
165-
params={'channel': channel, 'topic': topic})
165+
data={'channel': channel, 'topic': topic})
166166

167167

168168
class Channels(BaseAPI):
169169
def create(self, name):
170-
return self.post('channels.create', params={'name': name})
170+
return self.post('channels.create', data={'name': name})
171171

172172
def info(self, channel):
173173
return self.get('channels.info', params={'channel': channel})
@@ -189,39 +189,39 @@ def history(self, channel, latest=None, oldest=None, count=None,
189189

190190
def mark(self, channel, ts):
191191
return self.post('channels.mark',
192-
params={'channel': channel, 'ts': ts})
192+
data={'channel': channel, 'ts': ts})
193193

194194
def join(self, name):
195-
return self.post('channels.join', params={'name': name})
195+
return self.post('channels.join', data={'name': name})
196196

197197
def leave(self, channel):
198-
return self.post('channels.leave', params={'channel': channel})
198+
return self.post('channels.leave', data={'channel': channel})
199199

200200
def invite(self, channel, user):
201201
return self.post('channels.invite',
202-
params={'channel': channel, 'user': user})
202+
data={'channel': channel, 'user': user})
203203

204204
def kick(self, channel, user):
205205
return self.post('channels.kick',
206-
params={'channel': channel, 'user': user})
206+
data={'channel': channel, 'user': user})
207207

208208
def rename(self, channel, name):
209209
return self.post('channels.rename',
210-
params={'channel': channel, 'name': name})
210+
data={'channel': channel, 'name': name})
211211

212212
def archive(self, channel):
213-
return self.post('channels.archive', params={'channel': channel})
213+
return self.post('channels.archive', data={'channel': channel})
214214

215215
def unarchive(self, channel):
216-
return self.post('channels.unarchive', params={'channel': channel})
216+
return self.post('channels.unarchive', data={'channel': channel})
217217

218218
def set_purpose(self, channel, purpose):
219219
return self.post('channels.setPurpose',
220-
params={'channel': channel, 'purpose': purpose})
220+
data={'channel': channel, 'purpose': purpose})
221221

222222
def set_topic(self, channel, topic):
223223
return self.post('channels.setTopic',
224-
params={'channel': channel, 'topic': topic})
224+
data={'channel': channel, 'topic': topic})
225225

226226
def get_channel_id(self, channel_name):
227227
channels = self.list().body['channels']
@@ -239,7 +239,7 @@ def post_message(self, channel, text, username=None, as_user=None, parse=None,
239239
attachments = json.dumps(attachments)
240240

241241
return self.post('chat.postMessage',
242-
params={
242+
data={
243243
'channel': channel,
244244
'text': text,
245245
'username': username,
@@ -255,10 +255,10 @@ def post_message(self, channel, text, username=None, as_user=None, parse=None,
255255

256256
def update(self, channel, ts, text):
257257
self.post('chat.update',
258-
params={'channel': channel, 'ts': ts, 'text': text})
258+
data={'channel': channel, 'ts': ts, 'text': text})
259259

260260
def delete(self, channel, ts):
261-
self.post('chat.delete', params={'channel': channel, 'ts': ts})
261+
self.post('chat.delete', data={'channel': channel, 'ts': ts})
262262

263263

264264
class IM(BaseAPI):
@@ -277,13 +277,13 @@ def history(self, channel, latest=None, oldest=None, count=None,
277277
})
278278

279279
def mark(self, channel, ts):
280-
return self.post('im.mark', params={'channel': channel, 'ts': ts})
280+
return self.post('im.mark', data={'channel': channel, 'ts': ts})
281281

282282
def open(self, user):
283-
return self.post('im.open', params={'user': user})
283+
return self.post('im.open', data={'user': user})
284284

285285
def close(self, channel):
286-
return self.post('im.close', params={'channel': channel})
286+
return self.post('im.close', data={'channel': channel})
287287

288288

289289
class Search(BaseAPI):
@@ -348,7 +348,7 @@ def upload(self, file_, content=None, filetype=None, filename=None,
348348
channels = ','.join(channels)
349349

350350
return self.post('files.upload',
351-
params={
351+
data={
352352
'content': content,
353353
'filetype': filetype,
354354
'filename': filename,
@@ -359,7 +359,7 @@ def upload(self, file_, content=None, filetype=None, filename=None,
359359
files={'file': f})
360360

361361
def delete(self, file_):
362-
return self.post('files.delete', params={'file': file_})
362+
return self.post('files.delete', data={'file': file_})
363363

364364

365365
class Stars(BaseAPI):
@@ -380,7 +380,7 @@ class Presence(BaseAPI):
380380

381381
def set(self, presence):
382382
assert presence in Presence.TYPES, 'Invalid presence type'
383-
return self.post('presence.set', params={'presence': presence})
383+
return self.post('presence.set', data={'presence': presence})
384384

385385

386386
class RTM(BaseAPI):
@@ -405,7 +405,7 @@ def add(self, name, file_=None, file_comment=None, channel=None,
405405
assert (file_ or file_comment) or (channel and timestamp)
406406

407407
return self.post('reactions.add',
408-
params={
408+
data={
409409
'name': name,
410410
'file': file_,
411411
'file_comment': file_comment,
@@ -440,7 +440,7 @@ def remove(self, name, file_=None, file_comment=None, channel=None,
440440
assert (file_ or file_comment) or (channel and timestamp)
441441

442442
return self.post('reactions.remove',
443-
params={
443+
data={
444444
'name': name,
445445
'file': file_,
446446
'file_comment': file_comment,
@@ -452,7 +452,7 @@ def remove(self, name, file_=None, file_comment=None, channel=None,
452452
class OAuth(BaseAPI):
453453
def access(self, client_id, client_secret, code, redirect_uri=None):
454454
return self.post('oauth.access',
455-
params={
455+
data={
456456
'client_id': client_id,
457457
'client_secret': client_secret,
458458
'code': code,

0 commit comments

Comments
 (0)