|
38 | 38 | EVENT_REMINDER_TIMEDELTA, |
39 | 39 | HOST_REQUEST_MAX_REMINDERS, |
40 | 40 | HOST_REQUEST_REMINDER_INTERVAL, |
| 41 | + MODERATION_AUTO_APPROVE_FLAG_PRIORITY, |
41 | 42 | ) |
42 | 43 | from couchers.context import make_background_user_context, make_notification_user_context |
43 | 44 | from couchers.crypto import ( |
@@ -1544,8 +1545,10 @@ def check_database_consistency(payload: empty_pb2.Empty) -> None: |
1544 | 1545 |
|
1545 | 1546 | def auto_approve_moderation_queue(payload: empty_pb2.Empty) -> None: |
1546 | 1547 | """ |
1547 | | - Dead man's switch: auto-approves unresolved INITIAL_REVIEW items older than the deadline. |
1548 | | - Items explicitly actioned by moderators are left alone. |
| 1548 | + Dead man's switch: approves unresolved INITIAL_REVIEW content older than the deadline to VISIBLE, then |
| 1549 | + re-flags it as a high-priority MACHINE_FLAG superseding only the INITIAL_REVIEW item. The switch only fires |
| 1550 | + when moderators are behind, so every auto-approved item stays in the queue for a human to check. Other open |
| 1551 | + flags are untouched, and items already actioned by moderators are left alone. |
1549 | 1552 | """ |
1550 | 1553 | deadline_seconds = config.MODERATION_AUTO_APPROVE_DEADLINE_SECONDS |
1551 | 1554 | if deadline_seconds <= 0: |
@@ -1578,13 +1581,27 @@ def auto_approve_moderation_queue(payload: empty_pb2.Empty) -> None: |
1578 | 1581 | return |
1579 | 1582 |
|
1580 | 1583 | logger.info(f"Auto-approving {len(approvable)} moderation queue items") |
| 1584 | + reason = f"Auto-approved: moderation deadline of {deadline_seconds} seconds exceeded." |
1581 | 1585 | for item in approvable: |
1582 | 1586 | Moderation().ModerateContent( |
1583 | 1587 | request=moderation_pb2.ModerateContentReq( |
1584 | 1588 | moderation_state_id=item.moderation_state_id, |
1585 | 1589 | action=moderation_pb2.MODERATION_ACTION_APPROVE, |
1586 | 1590 | visibility=moderation_pb2.MODERATION_VISIBILITY_VISIBLE, |
1587 | | - reason=f"Auto-approved: moderation deadline of {deadline_seconds} seconds exceeded.", |
| 1591 | + reason=reason, |
| 1592 | + clear_flags=False, |
| 1593 | + ), |
| 1594 | + context=ctx, |
| 1595 | + session=session, |
| 1596 | + ) |
| 1597 | + Moderation().ModerateContent( |
| 1598 | + request=moderation_pb2.ModerateContentReq( |
| 1599 | + moderation_state_id=item.moderation_state_id, |
| 1600 | + action=moderation_pb2.MODERATION_ACTION_FLAG, |
| 1601 | + trigger=moderation_pb2.MODERATION_TRIGGER_MACHINE_FLAG, |
| 1602 | + priority=MODERATION_AUTO_APPROVE_FLAG_PRIORITY, |
| 1603 | + reason=reason, |
| 1604 | + supersede_queue_item_id=item.queue_item_id, |
1588 | 1605 | ), |
1589 | 1606 | context=ctx, |
1590 | 1607 | session=session, |
|
0 commit comments