comms: retry room leave actions
This commit is contained in:
parent
31ca499c04
commit
7860003f15
@ -2,7 +2,7 @@
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: bstein-leave-rooms-3
|
||||
name: bstein-leave-rooms-4
|
||||
namespace: comms
|
||||
spec:
|
||||
backoffLimit: 0
|
||||
@ -150,20 +150,26 @@ spec:
|
||||
try:
|
||||
for room_id in TARGET_ROOMS:
|
||||
room_q = urllib.parse.quote(room_id, safe="")
|
||||
leave_status, _ = http_json(
|
||||
"POST",
|
||||
f"{SYNAPSE_BASE}/_matrix/client/v3/rooms/{room_q}/leave",
|
||||
headers={"Authorization": f"Bearer {personal_token}"},
|
||||
json_body={},
|
||||
timeout=30,
|
||||
)
|
||||
forget_status, _ = http_json(
|
||||
"POST",
|
||||
f"{SYNAPSE_BASE}/_matrix/client/v3/rooms/{room_q}/forget",
|
||||
headers={"Authorization": f"Bearer {personal_token}"},
|
||||
json_body={},
|
||||
timeout=30,
|
||||
)
|
||||
leave_status = 0
|
||||
forget_status = 0
|
||||
for attempt in range(1, 6):
|
||||
leave_status, _ = http_json(
|
||||
"POST",
|
||||
f"{SYNAPSE_BASE}/_matrix/client/v3/rooms/{room_q}/leave",
|
||||
headers={"Authorization": f"Bearer {personal_token}"},
|
||||
json_body={},
|
||||
timeout=30,
|
||||
)
|
||||
forget_status, _ = http_json(
|
||||
"POST",
|
||||
f"{SYNAPSE_BASE}/_matrix/client/v3/rooms/{room_q}/forget",
|
||||
headers={"Authorization": f"Bearer {personal_token}"},
|
||||
json_body={},
|
||||
timeout=30,
|
||||
)
|
||||
if leave_status == 200 and forget_status == 200:
|
||||
break
|
||||
time.sleep(attempt * 2)
|
||||
results["rooms"][room_id] = {"leave": leave_status, "forget": forget_status}
|
||||
if leave_status != 200 or forget_status != 200:
|
||||
failures.append(room_id)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user