Ports the gooyal notifications client (as already used by advertising) and wires it into the previously-empty PushPublisher: on each message send, the other conversation participant(s) get a push notification with the sender's name and a message preview. Failures are swallowed per-recipient so a down notifications service degrades silently rather than breaking message sending. Requires NOTIFICATIONS_BASE_PUBLIC_URL and the notifications.application.push:send OAuth2 scope to be configured before it will actually deliver. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
102 lines
3 KiB
Python
102 lines
3 KiB
Python
from collections.abc import Mapping
|
|
from typing import Any, TypeVar, Union, cast
|
|
from uuid import UUID
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
|
|
from ..types import UNSET, Unset
|
|
|
|
T = TypeVar("T", bound="PushUser")
|
|
|
|
|
|
@_attrs_define
|
|
class PushUser:
|
|
"""
|
|
Attributes:
|
|
user (UUID):
|
|
client_token (Union[None, Unset, str]):
|
|
application_token (Union[None, Unset, str]):
|
|
"""
|
|
|
|
user: UUID
|
|
client_token: Union[None, Unset, str] = UNSET
|
|
application_token: Union[None, Unset, str] = UNSET
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
user = str(self.user)
|
|
|
|
client_token: Union[None, Unset, str]
|
|
if isinstance(self.client_token, Unset):
|
|
client_token = UNSET
|
|
else:
|
|
client_token = self.client_token
|
|
|
|
application_token: Union[None, Unset, str]
|
|
if isinstance(self.application_token, Unset):
|
|
application_token = UNSET
|
|
else:
|
|
application_token = self.application_token
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"user": user,
|
|
}
|
|
)
|
|
if client_token is not UNSET:
|
|
field_dict["client_token"] = client_token
|
|
if application_token is not UNSET:
|
|
field_dict["application_token"] = application_token
|
|
|
|
return field_dict
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
d = dict(src_dict)
|
|
user = UUID(d.pop("user"))
|
|
|
|
def _parse_client_token(data: object) -> Union[None, Unset, str]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Union[None, Unset, str], data)
|
|
|
|
client_token = _parse_client_token(d.pop("client_token", UNSET))
|
|
|
|
def _parse_application_token(data: object) -> Union[None, Unset, str]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Union[None, Unset, str], data)
|
|
|
|
application_token = _parse_application_token(d.pop("application_token", UNSET))
|
|
|
|
push_user = cls(
|
|
user=user,
|
|
client_token=client_token,
|
|
application_token=application_token,
|
|
)
|
|
|
|
push_user.additional_properties = d
|
|
return push_user
|
|
|
|
@property
|
|
def additional_keys(self) -> list[str]:
|
|
return list(self.additional_properties.keys())
|
|
|
|
def __getitem__(self, key: str) -> Any:
|
|
return self.additional_properties[key]
|
|
|
|
def __setitem__(self, key: str, value: Any) -> None:
|
|
self.additional_properties[key] = value
|
|
|
|
def __delitem__(self, key: str) -> None:
|
|
del self.additional_properties[key]
|
|
|
|
def __contains__(self, key: str) -> bool:
|
|
return key in self.additional_properties
|