aboutsummaryrefslogtreecommitdiff
path: root/demo.sh
blob: 00b4ff6909f944a26427a4b7f05c03dc85ebfc03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash

# JCHAT Demo Setup Script
# Creates sample conversations and messages for testing

set -e

SERVER_URL="http://localhost:8080"
CLIENT_URL="http://localhost:3000"

echo "🚀 JCHAT Demo Setup"
echo "==================="

# Check if server is running
echo "📡 Checking server status..."
if curl -f -s "${SERVER_URL}/jmap/session" > /dev/null; then
    echo "✅ Server is running at ${SERVER_URL}"
else
    echo "❌ Server is not running at ${SERVER_URL}"
    echo "   Start the server with: cd server && make run"
    exit 1
fi

# Test JMAP connection
echo "🔍 Testing JMAP connection..."
SESSION=$(curl -s "${SERVER_URL}/jmap/session")
echo "   Session capabilities: $(echo $SESSION | grep -o '"urn:ietf:params:jmap:[^"]*"' | wc -l) found"

# Create sample conversations using JMAP
echo "💬 Creating sample conversations..."

# Conversation 1: General Chat
echo "   Creating 'General Chat' conversation..."
curl -s -X POST "${SERVER_URL}/jmap/api" \
  -H "Content-Type: application/json" \
  -d '{
    "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:chat"],
    "methodCalls": [
      ["Conversation/set", {
        "accountId": "default",
        "create": {
          "conv1": {
            "title": "General Chat",
            "description": "General discussion for everyone",
            "participantIds": ["alice", "bob", "charlie"]
          }
        }
      }, "c1"]
    ]
  }' | jq '.' > /dev/null

# Conversation 2: Project Planning  
echo "   Creating 'Project Planning' conversation..."
curl -s -X POST "${SERVER_URL}/jmap/api" \
  -H "Content-Type: application/json" \
  -d '{
    "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:chat"],
    "methodCalls": [
      ["Conversation/set", {
        "accountId": "default", 
        "create": {
          "conv2": {
            "title": "Project Planning",
            "description": "Planning our next big project",
            "participantIds": ["alice", "bob"]
          }
        }
      }, "c1"]
    ]
  }' | jq '.' > /dev/null

echo "✅ Demo conversations created!"

echo ""
echo "🎯 Next Steps:"
echo "=============="
echo "1. Start the client: cd client && node server.js"
echo "2. Open your browser: ${CLIENT_URL}"
echo "3. Try creating messages and conversations"
echo ""
echo "🛠️  Development Commands:"
echo "========================"
echo "Server:"
echo "  cd server && make test     # Run tests"
echo "  cd server && make console  # Interactive shell"
echo ""
echo "Client:" 
echo "  cd client && node server.js  # Development server"
echo ""
echo "📋 API Endpoints:"
echo "================="
echo "  ${SERVER_URL}/jmap/session     # Session info"
echo "  ${SERVER_URL}/jmap/api         # JMAP API"
echo ""
echo "Happy chatting! 💬"