A community based topic aggregation platform built on atproto
at main 3.9 kB view raw
1#!/bin/bash 2 3# Script: 4-create-service-declaration.sh 4# Purpose: Create aggregator service declaration record 5# 6# This script writes a social.coves.aggregator.service record to your aggregator's repository. 7# This record contains metadata about your aggregator (name, description, etc.) and will be 8# indexed by Coves' Jetstream consumer into the aggregators table. 9 10set -e 11 12echo "================================================" 13echo "Step 4: Create Service Declaration" 14echo "================================================" 15echo "" 16 17# Load config if available 18if [ -f "aggregator-config.env" ]; then 19 source aggregator-config.env 20 echo "✓ Loaded configuration from aggregator-config.env" 21 echo " DID: $AGGREGATOR_DID" 22 echo " PDS URL: $AGGREGATOR_PDS_URL" 23 echo "" 24else 25 echo "Configuration file not found. Please run previous scripts first." 26 exit 1 27fi 28 29# Validate required fields 30if [ -z "$AGGREGATOR_ACCESS_JWT" ]; then 31 echo "Error: AGGREGATOR_ACCESS_JWT not set. Please run 1-create-pds-account.sh first." 32 exit 1 33fi 34 35echo "Enter aggregator metadata:" 36echo "" 37 38# Get metadata from user 39read -p "Display Name (e.g., 'RSS News Aggregator'): " DISPLAY_NAME 40read -p "Description: " DESCRIPTION 41read -p "Source URL (e.g., 'https://github.com/yourname/aggregator'): " SOURCE_URL 42read -p "Maintainer DID (your personal DID, optional): " MAINTAINER_DID 43 44if [ -z "$DISPLAY_NAME" ]; then 45 echo "Error: Display name is required" 46 exit 1 47fi 48 49echo "" 50echo "Creating service declaration record..." 51 52# Build the service record 53SERVICE_RECORD=$(cat <<EOF 54{ 55 "\$type": "social.coves.aggregator.service", 56 "did": "$AGGREGATOR_DID", 57 "displayName": "$DISPLAY_NAME", 58 "description": "$DESCRIPTION", 59 "sourceUrl": "$SOURCE_URL", 60 "maintainer": "$MAINTAINER_DID", 61 "createdAt": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" 62} 63EOF 64) 65 66# Call com.atproto.repo.createRecord 67RESPONSE=$(curl -s -X POST "$AGGREGATOR_PDS_URL/xrpc/com.atproto.repo.createRecord" \ 68 -H "Authorization: Bearer $AGGREGATOR_ACCESS_JWT" \ 69 -H "Content-Type: application/json" \ 70 -d "{ 71 \"repo\": \"$AGGREGATOR_DID\", 72 \"collection\": \"social.coves.aggregator.service\", 73 \"rkey\": \"self\", 74 \"record\": $SERVICE_RECORD 75 }") 76 77# Check if successful 78if echo "$RESPONSE" | jq -e '.error' > /dev/null 2>&1; then 79 echo "✗ Failed to create service declaration:" 80 echo "$RESPONSE" | jq '.' 81 exit 1 82fi 83 84# Extract response 85RECORD_URI=$(echo "$RESPONSE" | jq -r '.uri') 86RECORD_CID=$(echo "$RESPONSE" | jq -r '.cid') 87 88if [ -z "$RECORD_URI" ] || [ "$RECORD_URI" = "null" ]; then 89 echo "✗ Error: Unexpected response format" 90 echo "$RESPONSE" | jq '.' 91 exit 1 92fi 93 94echo "" 95echo "✓ Service declaration created successfully!" 96echo "" 97echo "=== Record Details ====" 98echo "URI: $RECORD_URI" 99echo "CID: $RECORD_CID" 100echo "=======================" 101echo "" 102 103# Save to config 104echo "" >> aggregator-config.env 105echo "SERVICE_DECLARATION_URI=\"$RECORD_URI\"" >> aggregator-config.env 106echo "SERVICE_DECLARATION_CID=\"$RECORD_CID\"" >> aggregator-config.env 107 108echo "✓ Updated aggregator-config.env" 109echo "" 110echo "================================================" 111echo "Setup Complete!" 112echo "================================================" 113echo "" 114echo "Your aggregator is now registered with Coves!" 115echo "" 116echo "Next steps:" 117echo "1. Wait a few seconds for Jetstream to index your service declaration" 118echo "2. Verify your aggregator appears in the aggregators list" 119echo "3. Community moderators can now authorize your aggregator" 120echo "4. Once authorized, you can start posting to communities" 121echo "" 122echo "To test posting, use the Coves XRPC endpoint:" 123echo " POST $COVES_INSTANCE_URL/xrpc/social.coves.community.post.create" 124echo "" 125echo "See docs/aggregators/SETUP_GUIDE.md for more information"