Skip to content

Commit 6df6bba

Browse files
committed
version 1.11.0
1 parent 68e792e commit 6df6bba

File tree

15 files changed

+396
-54
lines changed

15 files changed

+396
-54
lines changed

docs/api-docs/slack_bolt/adapter/falcon/resource.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1 class="title">Module <code>slack_bolt.adapter.falcon.resource</code></h1>
2626
<summary>
2727
<span>Expand source code</span>
2828
</summary>
29-
<pre><code class="python">from datetime import datetime
29+
<pre><code class="python">from datetime import datetime # type: ignore
3030
from http import HTTPStatus
3131

3232
from falcon import Request, Response

docs/api-docs/slack_bolt/adapter/flask/handler.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ <h1 class="title">Module <code>slack_bolt.adapter.flask.handler</code></h1>
4545
def to_flask_response(bolt_resp: BoltResponse) -&gt; Response:
4646
resp: Response = make_response(bolt_resp.body, bolt_resp.status)
4747
for k, values in bolt_resp.headers.items():
48+
if k.lower() == &#34;content-type&#34; and resp.headers.get(&#34;content-type&#34;) is not None:
49+
# Remove the one set by Flask
50+
resp.headers.pop(&#34;content-type&#34;)
4851
for v in values:
4952
resp.headers.add_header(k, v)
5053
return resp
@@ -107,6 +110,9 @@ <h2 class="section-title" id="header-functions">Functions</h2>
107110
<pre><code class="python">def to_flask_response(bolt_resp: BoltResponse) -&gt; Response:
108111
resp: Response = make_response(bolt_resp.body, bolt_resp.status)
109112
for k, values in bolt_resp.headers.items():
113+
if k.lower() == &#34;content-type&#34; and resp.headers.get(&#34;content-type&#34;) is not None:
114+
# Remove the one set by Flask
115+
resp.headers.pop(&#34;content-type&#34;)
110116
for v in values:
111117
resp.headers.add_header(k, v)
112118
return resp</code></pre>

docs/api-docs/slack_bolt/adapter/sanic/async_handler.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1 class="title">Module <code>slack_bolt.adapter.sanic.async_handler</code></h1
2626
<summary>
2727
<span>Expand source code</span>
2828
</summary>
29-
<pre><code class="python">from datetime import datetime
29+
<pre><code class="python">from datetime import datetime # type: ignore
3030

3131
from sanic.request import Request
3232
from sanic.response import HTTPResponse

docs/api-docs/slack_bolt/adapter/starlette/async_handler.html

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,30 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.async_handler</code>
2626
<summary>
2727
<span>Expand source code</span>
2828
</summary>
29-
<pre><code class="python">from starlette.requests import Request
29+
<pre><code class="python">from typing import Dict, Any, Optional
30+
31+
from starlette.requests import Request
3032
from starlette.responses import Response
3133

3234
from slack_bolt import BoltResponse
3335
from slack_bolt.async_app import AsyncApp, AsyncBoltRequest
3436
from slack_bolt.oauth.async_oauth_flow import AsyncOAuthFlow
3537

3638

37-
def to_async_bolt_request(req: Request, body: bytes) -&gt; AsyncBoltRequest:
38-
return AsyncBoltRequest(
39+
def to_async_bolt_request(
40+
req: Request,
41+
body: bytes,
42+
addition_context_properties: Optional[Dict[str, Any]] = None,
43+
) -&gt; AsyncBoltRequest:
44+
request = AsyncBoltRequest(
3945
body=body.decode(&#34;utf-8&#34;),
4046
query=req.query_params,
4147
headers=req.headers,
4248
)
49+
if addition_context_properties is not None:
50+
for k, v in addition_context_properties.items():
51+
request.context[k] = v
52+
return request
4353

4454

4555
def to_starlette_response(bolt_resp: BoltResponse) -&gt; Response:
@@ -67,23 +77,27 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.async_handler</code>
6777
def __init__(self, app: AsyncApp): # type: ignore
6878
self.app = app
6979

70-
async def handle(self, req: Request) -&gt; Response:
80+
async def handle(
81+
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
82+
) -&gt; Response:
7183
body = await req.body()
7284
if req.method == &#34;GET&#34;:
7385
if self.app.oauth_flow is not None:
7486
oauth_flow: AsyncOAuthFlow = self.app.oauth_flow
7587
if req.url.path == oauth_flow.install_path:
7688
bolt_resp = await oauth_flow.handle_installation(
77-
to_async_bolt_request(req, body)
89+
to_async_bolt_request(req, body, addition_context_properties)
7890
)
7991
return to_starlette_response(bolt_resp)
8092
elif req.url.path == oauth_flow.redirect_uri_path:
8193
bolt_resp = await oauth_flow.handle_callback(
82-
to_async_bolt_request(req, body)
94+
to_async_bolt_request(req, body, addition_context_properties)
8395
)
8496
return to_starlette_response(bolt_resp)
8597
elif req.method == &#34;POST&#34;:
86-
bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req, body))
98+
bolt_resp = await self.app.async_dispatch(
99+
to_async_bolt_request(req, body, addition_context_properties)
100+
)
87101
return to_starlette_response(bolt_resp)
88102

89103
return Response(
@@ -100,20 +114,28 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.async_handler</code>
100114
<h2 class="section-title" id="header-functions">Functions</h2>
101115
<dl>
102116
<dt id="slack_bolt.adapter.starlette.async_handler.to_async_bolt_request"><code class="name flex">
103-
<span>def <span class="ident">to_async_bolt_request</span></span>(<span>req: starlette.requests.Request, body: bytes) ‑> <a title="slack_bolt.request.async_request.AsyncBoltRequest" href="../../request/async_request.html#slack_bolt.request.async_request.AsyncBoltRequest">AsyncBoltRequest</a></span>
117+
<span>def <span class="ident">to_async_bolt_request</span></span>(<span>req: starlette.requests.Request, body: bytes, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> <a title="slack_bolt.request.async_request.AsyncBoltRequest" href="../../request/async_request.html#slack_bolt.request.async_request.AsyncBoltRequest">AsyncBoltRequest</a></span>
104118
</code></dt>
105119
<dd>
106120
<div class="desc"></div>
107121
<details class="source">
108122
<summary>
109123
<span>Expand source code</span>
110124
</summary>
111-
<pre><code class="python">def to_async_bolt_request(req: Request, body: bytes) -&gt; AsyncBoltRequest:
112-
return AsyncBoltRequest(
125+
<pre><code class="python">def to_async_bolt_request(
126+
req: Request,
127+
body: bytes,
128+
addition_context_properties: Optional[Dict[str, Any]] = None,
129+
) -&gt; AsyncBoltRequest:
130+
request = AsyncBoltRequest(
113131
body=body.decode(&#34;utf-8&#34;),
114132
query=req.query_params,
115133
headers=req.headers,
116-
)</code></pre>
134+
)
135+
if addition_context_properties is not None:
136+
for k, v in addition_context_properties.items():
137+
request.context[k] = v
138+
return request</code></pre>
117139
</details>
118140
</dd>
119141
<dt id="slack_bolt.adapter.starlette.async_handler.to_starlette_response"><code class="name flex">
@@ -165,23 +187,27 @@ <h2 class="section-title" id="header-classes">Classes</h2>
165187
def __init__(self, app: AsyncApp): # type: ignore
166188
self.app = app
167189

168-
async def handle(self, req: Request) -&gt; Response:
190+
async def handle(
191+
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
192+
) -&gt; Response:
169193
body = await req.body()
170194
if req.method == &#34;GET&#34;:
171195
if self.app.oauth_flow is not None:
172196
oauth_flow: AsyncOAuthFlow = self.app.oauth_flow
173197
if req.url.path == oauth_flow.install_path:
174198
bolt_resp = await oauth_flow.handle_installation(
175-
to_async_bolt_request(req, body)
199+
to_async_bolt_request(req, body, addition_context_properties)
176200
)
177201
return to_starlette_response(bolt_resp)
178202
elif req.url.path == oauth_flow.redirect_uri_path:
179203
bolt_resp = await oauth_flow.handle_callback(
180-
to_async_bolt_request(req, body)
204+
to_async_bolt_request(req, body, addition_context_properties)
181205
)
182206
return to_starlette_response(bolt_resp)
183207
elif req.method == &#34;POST&#34;:
184-
bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req, body))
208+
bolt_resp = await self.app.async_dispatch(
209+
to_async_bolt_request(req, body, addition_context_properties)
210+
)
185211
return to_starlette_response(bolt_resp)
186212

187213
return Response(
@@ -192,31 +218,35 @@ <h2 class="section-title" id="header-classes">Classes</h2>
192218
<h3>Methods</h3>
193219
<dl>
194220
<dt id="slack_bolt.adapter.starlette.async_handler.AsyncSlackRequestHandler.handle"><code class="name flex">
195-
<span>async def <span class="ident">handle</span></span>(<span>self, req: starlette.requests.Request) ‑> starlette.responses.Response</span>
221+
<span>async def <span class="ident">handle</span></span>(<span>self, req: starlette.requests.Request, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> starlette.responses.Response</span>
196222
</code></dt>
197223
<dd>
198224
<div class="desc"></div>
199225
<details class="source">
200226
<summary>
201227
<span>Expand source code</span>
202228
</summary>
203-
<pre><code class="python">async def handle(self, req: Request) -&gt; Response:
229+
<pre><code class="python">async def handle(
230+
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
231+
) -&gt; Response:
204232
body = await req.body()
205233
if req.method == &#34;GET&#34;:
206234
if self.app.oauth_flow is not None:
207235
oauth_flow: AsyncOAuthFlow = self.app.oauth_flow
208236
if req.url.path == oauth_flow.install_path:
209237
bolt_resp = await oauth_flow.handle_installation(
210-
to_async_bolt_request(req, body)
238+
to_async_bolt_request(req, body, addition_context_properties)
211239
)
212240
return to_starlette_response(bolt_resp)
213241
elif req.url.path == oauth_flow.redirect_uri_path:
214242
bolt_resp = await oauth_flow.handle_callback(
215-
to_async_bolt_request(req, body)
243+
to_async_bolt_request(req, body, addition_context_properties)
216244
)
217245
return to_starlette_response(bolt_resp)
218246
elif req.method == &#34;POST&#34;:
219-
bolt_resp = await self.app.async_dispatch(to_async_bolt_request(req, body))
247+
bolt_resp = await self.app.async_dispatch(
248+
to_async_bolt_request(req, body, addition_context_properties)
249+
)
220250
return to_starlette_response(bolt_resp)
221251

222252
return Response(

docs/api-docs/slack_bolt/adapter/starlette/handler.html

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,29 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.handler</code></h1>
2626
<summary>
2727
<span>Expand source code</span>
2828
</summary>
29-
<pre><code class="python">from starlette.requests import Request
29+
<pre><code class="python">from typing import Dict, Any, Optional
30+
31+
from starlette.requests import Request
3032
from starlette.responses import Response
3133

3234
from slack_bolt import BoltRequest, App, BoltResponse
3335
from slack_bolt.oauth import OAuthFlow
3436

3537

36-
def to_bolt_request(req: Request, body: bytes) -&gt; BoltRequest:
37-
return BoltRequest(
38+
def to_bolt_request(
39+
req: Request,
40+
body: bytes,
41+
addition_context_properties: Optional[Dict[str, Any]] = None,
42+
) -&gt; BoltRequest:
43+
request = BoltRequest(
3844
body=body.decode(&#34;utf-8&#34;),
3945
query=req.query_params,
4046
headers=req.headers,
4147
)
48+
if addition_context_properties is not None:
49+
for k, v in addition_context_properties.items():
50+
request.context[k] = v
51+
return request
4252

4353

4454
def to_starlette_response(bolt_resp: BoltResponse) -&gt; Response:
@@ -66,21 +76,27 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.handler</code></h1>
6676
def __init__(self, app: App): # type: ignore
6777
self.app = app
6878

69-
async def handle(self, req: Request) -&gt; Response:
79+
async def handle(
80+
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
81+
) -&gt; Response:
7082
body = await req.body()
7183
if req.method == &#34;GET&#34;:
7284
if self.app.oauth_flow is not None:
7385
oauth_flow: OAuthFlow = self.app.oauth_flow
7486
if req.url.path == oauth_flow.install_path:
7587
bolt_resp = oauth_flow.handle_installation(
76-
to_bolt_request(req, body)
88+
to_bolt_request(req, body, addition_context_properties)
7789
)
7890
return to_starlette_response(bolt_resp)
7991
elif req.url.path == oauth_flow.redirect_uri_path:
80-
bolt_resp = oauth_flow.handle_callback(to_bolt_request(req, body))
92+
bolt_resp = oauth_flow.handle_callback(
93+
to_bolt_request(req, body, addition_context_properties)
94+
)
8195
return to_starlette_response(bolt_resp)
8296
elif req.method == &#34;POST&#34;:
83-
bolt_resp = self.app.dispatch(to_bolt_request(req, body))
97+
bolt_resp = self.app.dispatch(
98+
to_bolt_request(req, body, addition_context_properties)
99+
)
84100
return to_starlette_response(bolt_resp)
85101

86102
return Response(
@@ -97,20 +113,28 @@ <h1 class="title">Module <code>slack_bolt.adapter.starlette.handler</code></h1>
97113
<h2 class="section-title" id="header-functions">Functions</h2>
98114
<dl>
99115
<dt id="slack_bolt.adapter.starlette.handler.to_bolt_request"><code class="name flex">
100-
<span>def <span class="ident">to_bolt_request</span></span>(<span>req: starlette.requests.Request, body: bytes) ‑> <a title="slack_bolt.request.request.BoltRequest" href="../../request/request.html#slack_bolt.request.request.BoltRequest">BoltRequest</a></span>
116+
<span>def <span class="ident">to_bolt_request</span></span>(<span>req: starlette.requests.Request, body: bytes, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> <a title="slack_bolt.request.request.BoltRequest" href="../../request/request.html#slack_bolt.request.request.BoltRequest">BoltRequest</a></span>
101117
</code></dt>
102118
<dd>
103119
<div class="desc"></div>
104120
<details class="source">
105121
<summary>
106122
<span>Expand source code</span>
107123
</summary>
108-
<pre><code class="python">def to_bolt_request(req: Request, body: bytes) -&gt; BoltRequest:
109-
return BoltRequest(
124+
<pre><code class="python">def to_bolt_request(
125+
req: Request,
126+
body: bytes,
127+
addition_context_properties: Optional[Dict[str, Any]] = None,
128+
) -&gt; BoltRequest:
129+
request = BoltRequest(
110130
body=body.decode(&#34;utf-8&#34;),
111131
query=req.query_params,
112132
headers=req.headers,
113-
)</code></pre>
133+
)
134+
if addition_context_properties is not None:
135+
for k, v in addition_context_properties.items():
136+
request.context[k] = v
137+
return request</code></pre>
114138
</details>
115139
</dd>
116140
<dt id="slack_bolt.adapter.starlette.handler.to_starlette_response"><code class="name flex">
@@ -162,21 +186,27 @@ <h2 class="section-title" id="header-classes">Classes</h2>
162186
def __init__(self, app: App): # type: ignore
163187
self.app = app
164188

165-
async def handle(self, req: Request) -&gt; Response:
189+
async def handle(
190+
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
191+
) -&gt; Response:
166192
body = await req.body()
167193
if req.method == &#34;GET&#34;:
168194
if self.app.oauth_flow is not None:
169195
oauth_flow: OAuthFlow = self.app.oauth_flow
170196
if req.url.path == oauth_flow.install_path:
171197
bolt_resp = oauth_flow.handle_installation(
172-
to_bolt_request(req, body)
198+
to_bolt_request(req, body, addition_context_properties)
173199
)
174200
return to_starlette_response(bolt_resp)
175201
elif req.url.path == oauth_flow.redirect_uri_path:
176-
bolt_resp = oauth_flow.handle_callback(to_bolt_request(req, body))
202+
bolt_resp = oauth_flow.handle_callback(
203+
to_bolt_request(req, body, addition_context_properties)
204+
)
177205
return to_starlette_response(bolt_resp)
178206
elif req.method == &#34;POST&#34;:
179-
bolt_resp = self.app.dispatch(to_bolt_request(req, body))
207+
bolt_resp = self.app.dispatch(
208+
to_bolt_request(req, body, addition_context_properties)
209+
)
180210
return to_starlette_response(bolt_resp)
181211

182212
return Response(
@@ -187,29 +217,35 @@ <h2 class="section-title" id="header-classes">Classes</h2>
187217
<h3>Methods</h3>
188218
<dl>
189219
<dt id="slack_bolt.adapter.starlette.handler.SlackRequestHandler.handle"><code class="name flex">
190-
<span>async def <span class="ident">handle</span></span>(<span>self, req: starlette.requests.Request) ‑> starlette.responses.Response</span>
220+
<span>async def <span class="ident">handle</span></span>(<span>self, req: starlette.requests.Request, addition_context_properties: Optional[Dict[str, Any]] = None) ‑> starlette.responses.Response</span>
191221
</code></dt>
192222
<dd>
193223
<div class="desc"></div>
194224
<details class="source">
195225
<summary>
196226
<span>Expand source code</span>
197227
</summary>
198-
<pre><code class="python">async def handle(self, req: Request) -&gt; Response:
228+
<pre><code class="python">async def handle(
229+
self, req: Request, addition_context_properties: Optional[Dict[str, Any]] = None
230+
) -&gt; Response:
199231
body = await req.body()
200232
if req.method == &#34;GET&#34;:
201233
if self.app.oauth_flow is not None:
202234
oauth_flow: OAuthFlow = self.app.oauth_flow
203235
if req.url.path == oauth_flow.install_path:
204236
bolt_resp = oauth_flow.handle_installation(
205-
to_bolt_request(req, body)
237+
to_bolt_request(req, body, addition_context_properties)
206238
)
207239
return to_starlette_response(bolt_resp)
208240
elif req.url.path == oauth_flow.redirect_uri_path:
209-
bolt_resp = oauth_flow.handle_callback(to_bolt_request(req, body))
241+
bolt_resp = oauth_flow.handle_callback(
242+
to_bolt_request(req, body, addition_context_properties)
243+
)
210244
return to_starlette_response(bolt_resp)
211245
elif req.method == &#34;POST&#34;:
212-
bolt_resp = self.app.dispatch(to_bolt_request(req, body))
246+
bolt_resp = self.app.dispatch(
247+
to_bolt_request(req, body, addition_context_properties)
248+
)
213249
return to_starlette_response(bolt_resp)
214250

215251
return Response(

docs/api-docs/slack_bolt/adapter/tornado/handler.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1 class="title">Module <code>slack_bolt.adapter.tornado.handler</code></h1>
2626
<summary>
2727
<span>Expand source code</span>
2828
</summary>
29-
<pre><code class="python">from datetime import datetime
29+
<pre><code class="python">from datetime import datetime # type: ignore
3030

3131
from tornado.httputil import HTTPServerRequest
3232
from tornado.web import RequestHandler

0 commit comments

Comments
 (0)