Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Update type of EventContext.rejected #13460

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/13460.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update type of `EventContext.rejected`.
7 changes: 3 additions & 4 deletions synapse/events/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING, List, Optional, Tuple, Union
from typing import TYPE_CHECKING, List, Optional, Tuple

import attr
from frozendict import frozendict
from typing_extensions import Literal

from synapse.appservice import ApplicationService
from synapse.events import EventBase
Expand All @@ -33,7 +32,7 @@ class EventContext:
Holds information relevant to persisting an event

Attributes:
rejected: A rejection reason if the event was rejected, else False
rejected: A rejection reason if the event was rejected, else None

_state_group: The ID of the state group for this event. Note that state events
are persisted with a state group which includes the new event, so this is
Expand Down Expand Up @@ -85,7 +84,7 @@ class EventContext:
"""

_storage: "StorageControllers"
rejected: Union[Literal[False], str] = False
rejected: Optional[str] = None
_state_group: Optional[int] = None
state_group_before_event: Optional[int] = None
_state_delta_due_to_event: Optional[StateMap[str]] = None
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/databases/main/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ def event_dict(event: EventBase) -> JsonDict:
event.sender,
"url" in event.content and isinstance(event.content["url"], str),
event.get_state_key(),
context.rejected or None,
context.rejected,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty string is not a valid rejection reason, so this is equivalent.

)
for event, context in events_and_contexts
),
Expand Down