- Reset master to upstream/main (16,697 commits) - Overlay 2,271 local-only files (skills, tools, workspace, configs, apps) - Restore IDENTITY.md and USER.md templates - Build verified, gateway running, Discord working Co-Authored-By: Claude Opus 4.6 <[email protected]>
93 lines
3.5 KiB
Bash
93 lines
3.5 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
log(){ echo "[$(date +%H:%M:%S)] $*" >&2; }
|
|
|
|
# ---- Gmail: mark unread in Promotions/Social/Forums/Updates as read ----
|
|
mark_gmail_query(){
|
|
local q="$1"
|
|
log "Gmail: search $q"
|
|
local json ids count
|
|
json=$(npx -y mcporter call --server google-workspace --tool "gmail.search" \
|
|
--args "{\"query\":\"$q\",\"maxResults\":500}" \
|
|
--timeout 60000 --output json)
|
|
ids=$(echo "$json" | jq -r ".messages[].id" || true)
|
|
count=$(echo "$ids" | sed '/^$/d' | wc -l)
|
|
log "Gmail: $count to mark read for [$q]"
|
|
local n=0
|
|
for id in $ids; do
|
|
n=$((n+1))
|
|
npx -y mcporter call --server google-workspace --tool "gmail.modify" \
|
|
--args "{\"messageId\":\"$id\",\"removeLabelIds\":[\"UNREAD\"]}" \
|
|
--timeout 60000 --output json >/dev/null
|
|
if (( n % 50 == 0 )); then log "Gmail: ...$n/$count for [$q]"; fi
|
|
done
|
|
}
|
|
|
|
mark_gmail_query "is:unread category:promotions"
|
|
mark_gmail_query "is:unread category:social"
|
|
mark_gmail_query "is:unread category:forums"
|
|
mark_gmail_query "is:unread category:updates"
|
|
|
|
# ---- Outlook: mark unread in low-importance folders as read ----
|
|
mark_outlook_folder(){
|
|
local profileDir="$1"
|
|
local folderName="$2"
|
|
|
|
OUTLOOK_CONFIG_DIR="$profileDir" /home/alex/clawd/skills/outlook/scripts/outlook-token.sh refresh >/dev/null || true
|
|
local token
|
|
token=$(OUTLOOK_CONFIG_DIR="$profileDir" /home/alex/clawd/skills/outlook/scripts/outlook-token.sh get 2>/dev/null || true)
|
|
if [ -z "$token" ]; then
|
|
log "Outlook($profileDir): no token, skipping"
|
|
return
|
|
fi
|
|
|
|
# Resolve folder id
|
|
local folders folderId
|
|
folders=$(curl -s "https://graph.microsoft.com/v1.0/me/mailFolders?\$top=200&\$select=id,displayName" -H "Authorization: Bearer $token")
|
|
folderId=$(echo "$folders" | jq -r --arg n "$folderName" ".value[] | select(.displayName==\$n) | .id" | head -n 1)
|
|
if [ -z "$folderId" ] || [ "$folderId" = "null" ]; then
|
|
log "Outlook($profileDir): folder not found: $folderName"
|
|
return
|
|
fi
|
|
|
|
log "Outlook($profileDir): marking unread in folder [$folderName]"
|
|
|
|
local url
|
|
url="https://graph.microsoft.com/v1.0/me/mailFolders/$folderId/messages?\$filter=isRead%20eq%20false&\$top=200&\$select=id"
|
|
|
|
local total=0
|
|
while [ -n "$url" ]; do
|
|
local page ids
|
|
page=$(curl -s "$url" -H "Authorization: Bearer $token")
|
|
ids=$(echo "$page" | jq -r ".value[].id")
|
|
for id in $ids; do
|
|
total=$((total+1))
|
|
curl -s -X PATCH "https://graph.microsoft.com/v1.0/me/messages/$id" \
|
|
-H "Authorization: Bearer $token" -H "Content-Type: application/json" \
|
|
-d '{"isRead":true}' >/dev/null
|
|
if (( total % 100 == 0 )); then log "Outlook($profileDir): ...$total"; fi
|
|
done
|
|
url=$(echo "$page" | jq -r '."@odata.nextLink" // empty')
|
|
done
|
|
|
|
log "Outlook($profileDir): done folder [$folderName] (marked $total)"
|
|
}
|
|
|
|
for prof in "$HOME/.outlook-mcp-personal" "$HOME/.outlook-mcp-o365"; do
|
|
mark_outlook_folder "$prof" "Uønsket mail"
|
|
mark_outlook_folder "$prof" "SPAMfighter"
|
|
mark_outlook_folder "$prof" "RSS-abonnementer"
|
|
mark_outlook_folder "$prof" "RSS-kilder"
|
|
mark_outlook_folder "$prof" "Samtalehistorik"
|
|
mark_outlook_folder "$prof" "Synkroniseringsproblemer"
|
|
mark_outlook_folder "$prof" "Synkroniseringsfejl"
|
|
mark_outlook_folder "$prof" "Infected Items"
|
|
mark_outlook_folder "$prof" "Infected Items_0"
|
|
mark_outlook_folder "$prof" "Inficerede elementer"
|
|
mark_outlook_folder "$prof" "Detected Items"
|
|
mark_outlook_folder "$prof" "Trash"
|
|
mark_outlook_folder "$prof" "Slettet post"
|
|
done
|
|
|
|
log "All done." |