sockudo-http-python 2.0.0__py3-none-any.whl → 2.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sockudo_http_python/client.py +26 -2
- {sockudo_http_python-2.0.0.dist-info → sockudo_http_python-2.1.0.dist-info}/METADATA +2 -9
- sockudo_http_python-2.1.0.dist-info/RECORD +8 -0
- sockudo_http_python-2.0.0.dist-info/RECORD +0 -8
- {sockudo_http_python-2.0.0.dist-info → sockudo_http_python-2.1.0.dist-info}/WHEEL +0 -0
- {sockudo_http_python-2.0.0.dist-info → sockudo_http_python-2.1.0.dist-info}/licenses/LICENSE +0 -0
- {sockudo_http_python-2.0.0.dist-info → sockudo_http_python-2.1.0.dist-info}/top_level.txt +0 -0
sockudo_http_python/client.py
CHANGED
|
@@ -387,6 +387,19 @@ class WebhookEvent:
|
|
|
387
387
|
data: Optional[Any] = None
|
|
388
388
|
socket_id: Optional[str] = None
|
|
389
389
|
user_id: Optional[str] = None
|
|
390
|
+
raw: Mapping[str, Any] = field(default_factory=dict)
|
|
391
|
+
|
|
392
|
+
@staticmethod
|
|
393
|
+
def from_payload(payload: Mapping[str, Any]) -> "WebhookEvent":
|
|
394
|
+
return WebhookEvent(
|
|
395
|
+
name=_optional_string(payload.get("name")) or "",
|
|
396
|
+
channel=_optional_string(payload.get("channel")),
|
|
397
|
+
event=_optional_string(payload.get("event")),
|
|
398
|
+
data=payload.get("data"),
|
|
399
|
+
socket_id=_optional_string(payload.get("socket_id")),
|
|
400
|
+
user_id=_optional_string(payload.get("user_id")),
|
|
401
|
+
raw=dict(payload),
|
|
402
|
+
)
|
|
390
403
|
|
|
391
404
|
|
|
392
405
|
@dataclass(frozen=True)
|
|
@@ -398,7 +411,11 @@ class Webhook:
|
|
|
398
411
|
def parse(body: Union[str, bytes]) -> "Webhook":
|
|
399
412
|
text = body.decode("utf-8") if isinstance(body, bytes) else body
|
|
400
413
|
raw = json.loads(text)
|
|
401
|
-
events = tuple(
|
|
414
|
+
events = tuple(
|
|
415
|
+
WebhookEvent.from_payload(event)
|
|
416
|
+
for event in raw.get("events", [])
|
|
417
|
+
if isinstance(event, Mapping)
|
|
418
|
+
)
|
|
402
419
|
return Webhook(time_ms=raw.get("time_ms"), events=events)
|
|
403
420
|
|
|
404
421
|
|
|
@@ -702,13 +719,16 @@ class _BaseSockudo:
|
|
|
702
719
|
nacl_exceptions.CryptoError,
|
|
703
720
|
) as exc:
|
|
704
721
|
raise SockudoError("Failed to decrypt encrypted webhook event") from exc
|
|
722
|
+
raw = dict(event.raw)
|
|
723
|
+
raw["data"] = plaintext.decode("utf-8")
|
|
705
724
|
return WebhookEvent(
|
|
706
725
|
name=event.name,
|
|
707
726
|
channel=event.channel,
|
|
708
727
|
event=event.event,
|
|
709
|
-
data=
|
|
728
|
+
data=raw["data"],
|
|
710
729
|
socket_id=event.socket_id,
|
|
711
730
|
user_id=event.user_id,
|
|
731
|
+
raw=raw,
|
|
712
732
|
)
|
|
713
733
|
|
|
714
734
|
def _serialize(self, payload: Mapping[str, Any]) -> str:
|
|
@@ -1744,6 +1764,10 @@ def _clean_raw(values: Mapping[str, Any]) -> JsonDict:
|
|
|
1744
1764
|
return {key: value for key, value in values.items() if value is not None}
|
|
1745
1765
|
|
|
1746
1766
|
|
|
1767
|
+
def _optional_string(value: Any) -> Optional[str]:
|
|
1768
|
+
return value if isinstance(value, str) else None
|
|
1769
|
+
|
|
1770
|
+
|
|
1747
1771
|
def _clean_query(values: Mapping[str, Any]) -> Dict[str, str]:
|
|
1748
1772
|
return {key: str(value) for key, value in values.items() if value is not None}
|
|
1749
1773
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sockudo-http-python
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: High-performance Python HTTP server SDK for Sockudo
|
|
5
5
|
Author: Sockudo
|
|
6
6
|
License-Expression: MIT
|
|
@@ -46,14 +46,7 @@ For apps, install the published package:
|
|
|
46
46
|
pip install sockudo-http-python
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
For
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
git clone https://github.com/sockudo/sockudo.git
|
|
53
|
-
pip install -e sockudo/server-sdks/sockudo-http-python
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
For local development from this monorepo:
|
|
49
|
+
For contributors working inside this repository:
|
|
57
50
|
|
|
58
51
|
```bash
|
|
59
52
|
pip install -e server-sdks/sockudo-http-python[dev]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
sockudo_http/__init__.py,sha256=YvVKXlTgEp2u7Yf1p7ONWWKg1VauS6bm2dCByaX1s2c,53
|
|
2
|
+
sockudo_http_python/__init__.py,sha256=PsWB_Hn0BzSuM9Y8KNJnLYUWuzloqSwwRH3rIDJOm6o,1145
|
|
3
|
+
sockudo_http_python/client.py,sha256=WW4nrsRDnEJXJgTGfz3f_Ppa0LPrzLl2wcr2QwvX2Ck,61838
|
|
4
|
+
sockudo_http_python-2.1.0.dist-info/licenses/LICENSE,sha256=Rfu09RfZYgdX4dvZwzmFVt2wfFYH87DKhvRy886D8Os,1064
|
|
5
|
+
sockudo_http_python-2.1.0.dist-info/METADATA,sha256=PN7diDFrSSsy0R_XpTuVgH_l6bHty9jp4vNmfKpFu88,5750
|
|
6
|
+
sockudo_http_python-2.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
7
|
+
sockudo_http_python-2.1.0.dist-info/top_level.txt,sha256=saTZU7c-zhgTxNxavzQ5c0XSPa5G55wvsQLSq32R_4o,33
|
|
8
|
+
sockudo_http_python-2.1.0.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
sockudo_http/__init__.py,sha256=YvVKXlTgEp2u7Yf1p7ONWWKg1VauS6bm2dCByaX1s2c,53
|
|
2
|
-
sockudo_http_python/__init__.py,sha256=PsWB_Hn0BzSuM9Y8KNJnLYUWuzloqSwwRH3rIDJOm6o,1145
|
|
3
|
-
sockudo_http_python/client.py,sha256=42_P043iGslDmmjx--Nvpg9endgYItVhQg4DYcWLJkI,60998
|
|
4
|
-
sockudo_http_python-2.0.0.dist-info/licenses/LICENSE,sha256=Rfu09RfZYgdX4dvZwzmFVt2wfFYH87DKhvRy886D8Os,1064
|
|
5
|
-
sockudo_http_python-2.0.0.dist-info/METADATA,sha256=NgCRkr-RXzYDn1uZcLKD8D64F48pGceuccxpbMqj_ck,5922
|
|
6
|
-
sockudo_http_python-2.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
7
|
-
sockudo_http_python-2.0.0.dist-info/top_level.txt,sha256=saTZU7c-zhgTxNxavzQ5c0XSPa5G55wvsQLSq32R_4o,33
|
|
8
|
-
sockudo_http_python-2.0.0.dist-info/RECORD,,
|
|
File without changes
|
{sockudo_http_python-2.0.0.dist-info → sockudo_http_python-2.1.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|