mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-01-04 22:10:52 -05:00
Rename key and values for m.room.history_visibility. Support 'invited' value
This commit is contained in:
parent
c3e2600c67
commit
fb47c3cfbe
@ -75,7 +75,7 @@ def prune_event(event):
|
|||||||
elif event_type == EventTypes.Aliases:
|
elif event_type == EventTypes.Aliases:
|
||||||
add_fields("aliases")
|
add_fields("aliases")
|
||||||
elif event_type == EventTypes.RoomHistoryVisibility:
|
elif event_type == EventTypes.RoomHistoryVisibility:
|
||||||
add_fields("visibility")
|
add_fields("history_visibility")
|
||||||
|
|
||||||
allowed_fields = {
|
allowed_fields = {
|
||||||
k: v
|
k: v
|
||||||
|
@ -239,22 +239,28 @@ class FederationHandler(BaseHandler):
|
|||||||
return event
|
return event
|
||||||
|
|
||||||
history = state.get((EventTypes.RoomHistoryVisibility, ''), None)
|
history = state.get((EventTypes.RoomHistoryVisibility, ''), None)
|
||||||
if history and history.content.get("visibility", None) == "after_join":
|
if history:
|
||||||
for ev in state.values():
|
visibility = history.content.get("history_visibility", "shared")
|
||||||
if ev.type != EventTypes.Member:
|
if visibility in ["invited", "joined"]:
|
||||||
continue
|
for ev in state.values():
|
||||||
try:
|
if ev.type != EventTypes.Member:
|
||||||
domain = UserID.from_string(ev.state_key).domain
|
continue
|
||||||
except:
|
try:
|
||||||
continue
|
domain = UserID.from_string(ev.state_key).domain
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
if domain != server_name:
|
if domain != server_name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if ev.membership == Membership.JOIN:
|
memtype = ev.membership
|
||||||
return event
|
if memtype == Membership.JOIN:
|
||||||
else:
|
return event
|
||||||
return prune_event(event)
|
elif memtype == Membership.INVITE:
|
||||||
|
if visibility == "invited":
|
||||||
|
return event
|
||||||
|
else:
|
||||||
|
return prune_event(event)
|
||||||
|
|
||||||
return event
|
return event
|
||||||
|
|
||||||
|
@ -149,13 +149,29 @@ class MessageHandler(BaseHandler):
|
|||||||
if event.type == EventTypes.RoomHistoryVisibility:
|
if event.type == EventTypes.RoomHistoryVisibility:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
membership = state.get((EventTypes.Member, user_id), None)
|
membership_ev = state.get((EventTypes.Member, user_id), None)
|
||||||
if membership and membership.membership == Membership.JOIN:
|
if membership_ev:
|
||||||
|
membership = membership_ev.membership
|
||||||
|
else:
|
||||||
|
membership = Membership.LEAVE
|
||||||
|
|
||||||
|
if membership == Membership.JOIN:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
history = state.get((EventTypes.RoomHistoryVisibility, ''), None)
|
history = state.get((EventTypes.RoomHistoryVisibility, ''), None)
|
||||||
if history and history.content.get("visibility", None) == "after_join":
|
if history:
|
||||||
return False
|
visibility = history.content.get("history_visibility", "shared")
|
||||||
|
else:
|
||||||
|
visibility = "shared"
|
||||||
|
|
||||||
|
if visibility == "public":
|
||||||
|
return True
|
||||||
|
elif visibility == "shared":
|
||||||
|
return True
|
||||||
|
elif visibility == "joined":
|
||||||
|
return membership == Membership.JOIN
|
||||||
|
elif visibility == "invited":
|
||||||
|
return membership == Membership.INVITE
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -306,16 +306,31 @@ class SyncHandler(BaseHandler):
|
|||||||
if event.type == EventTypes.RoomHistoryVisibility:
|
if event.type == EventTypes.RoomHistoryVisibility:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
membership = state.get((EventTypes.Member, user_id), None)
|
membership_ev = state.get((EventTypes.Member, user_id), None)
|
||||||
if membership and membership.membership == Membership.JOIN:
|
if membership_ev:
|
||||||
|
membership = membership_ev.membership
|
||||||
|
else:
|
||||||
|
membership = Membership.LEAVE
|
||||||
|
|
||||||
|
if membership == Membership.JOIN:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
history = state.get((EventTypes.RoomHistoryVisibility, ''), None)
|
history = state.get((EventTypes.RoomHistoryVisibility, ''), None)
|
||||||
if history and history.content.get("visibility", None) == "after_join":
|
if history:
|
||||||
return False
|
visibility = history.content.get("history_visibility", "shared")
|
||||||
|
else:
|
||||||
|
visibility = "shared"
|
||||||
|
|
||||||
|
if visibility == "public":
|
||||||
|
return True
|
||||||
|
elif visibility == "shared":
|
||||||
|
return True
|
||||||
|
elif visibility == "joined":
|
||||||
|
return membership == Membership.JOIN
|
||||||
|
elif visibility == "invited":
|
||||||
|
return membership == Membership.INVITE
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
events_and_states = filter(allowed, events_and_states)
|
events_and_states = filter(allowed, events_and_states)
|
||||||
defer.returnValue([
|
defer.returnValue([
|
||||||
ev
|
ev
|
||||||
|
Loading…
Reference in New Issue
Block a user