xflog 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xflog/__init__.py +16 -0
- xflog/__main__.py +69 -0
- xflog/app.py +339 -0
- xflog/assets/FONT-LICENSE.txt +93 -0
- xflog/assets/activity-hud.css +306 -0
- xflog/assets/activity-hud.js +188 -0
- xflog/assets/app.css +458 -0
- xflog/assets/app.js +682 -0
- xflog/assets/audience-groups.js +40 -0
- xflog/assets/audience-ui.js +97 -0
- xflog/assets/brand.html +303 -0
- xflog/assets/constellation-colors.js +37 -0
- xflog/assets/constellation-layout.js +210 -0
- xflog/assets/constellation.css +564 -0
- xflog/assets/constellation.js +610 -0
- xflog/assets/empty-history.js +23 -0
- xflog/assets/follow-actions.css +90 -0
- xflog/assets/follow-actions.js +365 -0
- xflog/assets/fonts.css +6 -0
- xflog/assets/format.js +57 -0
- xflog/assets/interactions.css +356 -0
- xflog/assets/interactions.js +350 -0
- xflog/assets/journal.js +70 -0
- xflog/assets/live-history.js +61 -0
- xflog/assets/mark.svg +1 -0
- xflog/assets/notice.js +59 -0
- xflog/assets/notifications.js +51 -0
- xflog/assets/panels.css +290 -0
- xflog/assets/person-detail.js +32 -0
- xflog/assets/plex-sans-variable.ttf +0 -0
- xflog/assets/popover.js +60 -0
- xflog/assets/profile.js +50 -0
- xflog/assets/responsive.css +216 -0
- xflog/assets/selected-signal.js +100 -0
- xflog/assets/settings.css +339 -0
- xflog/assets/shell.html +615 -0
- xflog/assets/shooting-star.js +66 -0
- xflog/assets/timeline.css +476 -0
- xflog/assets/verification-badge.js +10 -0
- xflog/assets/wordmark.svg +1 -0
- xflog/audience_groups/__init__.py +114 -0
- xflog/audience_groups/account_age.py +60 -0
- xflog/audience_groups/account_size.py +41 -0
- xflog/audience_groups/activity.py +30 -0
- xflog/audience_groups/previous_encounters.py +48 -0
- xflog/audience_groups/profile_location.py +92 -0
- xflog/audience_groups/verification.py +48 -0
- xflog/config.py +123 -0
- xflog/errors.py +6 -0
- xflog/healthcheck.py +20 -0
- xflog/history/__init__.py +0 -0
- xflog/history/demo.py +153 -0
- xflog/history/filters.py +6 -0
- xflog/history/profiles.py +49 -0
- xflog/history/store.py +287 -0
- xflog/history/summary.py +87 -0
- xflog/history/timeline.py +144 -0
- xflog/interactions/__init__.py +185 -0
- xflog/interactions/history.py +219 -0
- xflog/interactions/store.py +178 -0
- xflog/ownership.py +34 -0
- xflog/profile_names.py +113 -0
- xflog/runtime.py +132 -0
- xflog/tracking/__init__.py +0 -0
- xflog/tracking/collector.py +449 -0
- xflog/tracking/events.py +96 -0
- xflog/tracking/follow_actions.py +201 -0
- xflog/tracking/tokens.py +153 -0
- xflog/tracking/transport.py +247 -0
- xflog/web/__init__.py +0 -0
- xflog/web/models.py +40 -0
- xflog/web/ui.py +39 -0
- xflog-1.0.0.dist-info/METADATA +509 -0
- xflog-1.0.0.dist-info/RECORD +79 -0
- xflog-1.0.0.dist-info/WHEEL +4 -0
- xflog-1.0.0.dist-info/entry_points.txt +2 -0
- xflog-1.0.0.dist-info/licenses/LICENSE +202 -0
- xflog-1.0.0.dist-info/licenses/NOTICE +7 -0
- xflog-1.0.0.dist-info/licenses/src/xflog/assets/FONT-LICENSE.txt +93 -0
xflog/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""XFlog — X Follower Log."""
|
|
2
|
+
|
|
3
|
+
from .config import CoreConfig
|
|
4
|
+
from .errors import RuntimeBusyError, SetupError
|
|
5
|
+
from .interactions.history import ThreadOptions
|
|
6
|
+
from .runtime import Runtime
|
|
7
|
+
from .tracking.transport import ProviderError
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"CoreConfig",
|
|
11
|
+
"ProviderError",
|
|
12
|
+
"Runtime",
|
|
13
|
+
"RuntimeBusyError",
|
|
14
|
+
"SetupError",
|
|
15
|
+
"ThreadOptions",
|
|
16
|
+
]
|
xflog/__main__.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import asyncio
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from .config import Config, CoreConfig
|
|
8
|
+
from .errors import SetupError
|
|
9
|
+
from .tracking.transport import ProviderError, XClient, provider_http
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
async def lookup_user_id(handle: str | None) -> str:
|
|
13
|
+
config = CoreConfig.from_env()
|
|
14
|
+
async with provider_http() as http:
|
|
15
|
+
return await XClient(config, http).lookup_user_id(handle)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def main(argv: list[str] | None = None) -> None:
|
|
19
|
+
parser = argparse.ArgumentParser(description="XFlog: run the UI or look up an X account ID.")
|
|
20
|
+
commands = parser.add_subparsers(dest="command")
|
|
21
|
+
lookup = commands.add_parser(
|
|
22
|
+
"user-id", help="Look up an account ID (one X read; X charges may apply)."
|
|
23
|
+
)
|
|
24
|
+
target = lookup.add_mutually_exclusive_group(required=True)
|
|
25
|
+
target.add_argument("handle", nargs="?", help="@handle, using X_APP_BEARER_TOKEN")
|
|
26
|
+
target.add_argument("--me", action="store_true", help="Use X_USER_ACCESS_TOKEN (OAuth 2.0)")
|
|
27
|
+
args = parser.parse_args(argv)
|
|
28
|
+
if args.command == "user-id":
|
|
29
|
+
try:
|
|
30
|
+
print(asyncio.run(lookup_user_id(args.handle)))
|
|
31
|
+
except (SetupError, ValueError) as error:
|
|
32
|
+
raise SystemExit(str(error)) from None
|
|
33
|
+
except ProviderError as error:
|
|
34
|
+
raise SystemExit(
|
|
35
|
+
f"X user lookup failed (HTTP {error.status}). "
|
|
36
|
+
"Check the account, token permissions, API access and credits."
|
|
37
|
+
) from None
|
|
38
|
+
except httpx.HTTPError:
|
|
39
|
+
raise SystemExit("Could not reach X. Check your connection and try again.") from None
|
|
40
|
+
return
|
|
41
|
+
serve()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def serve() -> None:
|
|
45
|
+
try:
|
|
46
|
+
import uvicorn
|
|
47
|
+
|
|
48
|
+
from .app import create_app
|
|
49
|
+
except ModuleNotFoundError as error:
|
|
50
|
+
if error.name not in {"uvicorn", "fastapi", "gradio"}:
|
|
51
|
+
raise
|
|
52
|
+
raise SystemExit(
|
|
53
|
+
'The browser UI is optional. Install it with: pip install "xflog[ui]" '
|
|
54
|
+
"(or use uv pip install with the same argument)."
|
|
55
|
+
) from None
|
|
56
|
+
config = Config.from_env()
|
|
57
|
+
logging.getLogger("httpx").setLevel(logging.CRITICAL)
|
|
58
|
+
logging.getLogger("httpcore").setLevel(logging.CRITICAL)
|
|
59
|
+
uvicorn.run(
|
|
60
|
+
create_app(config),
|
|
61
|
+
host=config.host,
|
|
62
|
+
port=config.port,
|
|
63
|
+
access_log=False,
|
|
64
|
+
proxy_headers=False,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
main()
|
xflog/app.py
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import secrets
|
|
3
|
+
import sqlite3
|
|
4
|
+
import time
|
|
5
|
+
from urllib.parse import urlsplit
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
from fastapi import FastAPI, HTTPException, Request
|
|
9
|
+
from fastapi.responses import JSONResponse
|
|
10
|
+
from fastapi.security import HTTPBasic
|
|
11
|
+
from fastapi.staticfiles import StaticFiles
|
|
12
|
+
from starlette.middleware.trustedhost import TrustedHostMiddleware
|
|
13
|
+
|
|
14
|
+
from . import audience_groups
|
|
15
|
+
from .config import ASSETS, Config
|
|
16
|
+
from .errors import SetupError
|
|
17
|
+
from .history.demo import demo_activity, demo_history
|
|
18
|
+
from .history.demo import encounter_context as demo_encounter_context
|
|
19
|
+
from .history.filters import valid_filters
|
|
20
|
+
from .history.summary import PERIODS, SUBJECT_TYPES, activity_window, readings
|
|
21
|
+
from .history.timeline import Timeline, decode_cursor
|
|
22
|
+
from .interactions import TYPES, catalog
|
|
23
|
+
from .interactions.history import ThreadOptions
|
|
24
|
+
from .profile_names import ProfileNames
|
|
25
|
+
from .runtime import Runtime
|
|
26
|
+
from .tracking.collector import DEFAULT_SELECTION
|
|
27
|
+
from .tracking.transport import ProviderError
|
|
28
|
+
from .web.models import (
|
|
29
|
+
AudiencePreferences,
|
|
30
|
+
FollowChange,
|
|
31
|
+
FollowTarget,
|
|
32
|
+
Selection,
|
|
33
|
+
StartRequest,
|
|
34
|
+
ThreadRequest,
|
|
35
|
+
)
|
|
36
|
+
from .web.ui import mount_ui as mount_browser_ui
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def create_app(config: Config | None = None, *, transport=None, mount_ui=True):
|
|
40
|
+
config = config or Config.from_env()
|
|
41
|
+
runtime = Runtime(config, transport=transport)
|
|
42
|
+
store, collector = runtime.store, runtime.collector
|
|
43
|
+
timeline = Timeline(store)
|
|
44
|
+
profile_names = ProfileNames(store, runtime.client)
|
|
45
|
+
follow_actions, interactions = runtime.follow_actions, runtime.interactions
|
|
46
|
+
sessions = {}
|
|
47
|
+
controls = asyncio.Lock()
|
|
48
|
+
|
|
49
|
+
app = FastAPI(lifespan=runtime.lifespan, docs_url=None, redoc_url=None, openapi_url=None)
|
|
50
|
+
app.state.store, app.state.collector = store, collector
|
|
51
|
+
app.state.client, app.state.sessions = runtime.client, sessions
|
|
52
|
+
app.state.runtime = runtime
|
|
53
|
+
app.state.follow_actions = follow_actions
|
|
54
|
+
app.state.interactions = interactions
|
|
55
|
+
app.add_middleware(TrustedHostMiddleware, allowed_hosts=[urlsplit(config.origin).hostname])
|
|
56
|
+
basic_auth = HTTPBasic(auto_error=False)
|
|
57
|
+
|
|
58
|
+
@app.middleware("http")
|
|
59
|
+
async def instance_security(request: Request, call_next):
|
|
60
|
+
if request.headers.get("host") != urlsplit(config.origin).netloc:
|
|
61
|
+
return JSONResponse({"detail": "Use the configured XFlog address."}, status_code=403)
|
|
62
|
+
if request.url.path != "/healthz" and config.admin_password:
|
|
63
|
+
try:
|
|
64
|
+
credentials = await basic_auth(request)
|
|
65
|
+
except HTTPException:
|
|
66
|
+
credentials = None
|
|
67
|
+
if not credentials or not (
|
|
68
|
+
secrets.compare_digest(credentials.username.encode(), b"xflog")
|
|
69
|
+
and secrets.compare_digest(
|
|
70
|
+
credentials.password.encode(), config.admin_password.encode()
|
|
71
|
+
)
|
|
72
|
+
):
|
|
73
|
+
return JSONResponse(
|
|
74
|
+
{"detail": "Instance authentication required."},
|
|
75
|
+
status_code=401,
|
|
76
|
+
headers={
|
|
77
|
+
"WWW-Authenticate": 'Basic realm="XFlog", charset="UTF-8"',
|
|
78
|
+
"Cache-Control": "no-store",
|
|
79
|
+
},
|
|
80
|
+
)
|
|
81
|
+
if request.headers.get("sec-fetch-site") in {"cross-site", "same-site"}:
|
|
82
|
+
return JSONResponse(
|
|
83
|
+
{"detail": "Open XFlog directly on its configured address."},
|
|
84
|
+
status_code=403,
|
|
85
|
+
)
|
|
86
|
+
session = request.cookies.get("xflog_session")
|
|
87
|
+
now = time.monotonic()
|
|
88
|
+
fresh = False
|
|
89
|
+
if request.url.path == "/" and request.method == "GET":
|
|
90
|
+
for key in [key for key, value in sessions.items() if value["expires"] < now]:
|
|
91
|
+
sessions.pop(key)
|
|
92
|
+
if session not in sessions:
|
|
93
|
+
if len(sessions) >= 100:
|
|
94
|
+
return JSONResponse(
|
|
95
|
+
{"detail": "Too many local browser sessions."}, status_code=429
|
|
96
|
+
)
|
|
97
|
+
session = secrets.token_urlsafe(32)
|
|
98
|
+
sessions[session] = {
|
|
99
|
+
"csrf": secrets.token_urlsafe(32),
|
|
100
|
+
"expires": now + 86400,
|
|
101
|
+
}
|
|
102
|
+
fresh = True
|
|
103
|
+
protected = request.url.path.startswith("/api/")
|
|
104
|
+
current = sessions.get(session)
|
|
105
|
+
if protected and (not current or current["expires"] < now):
|
|
106
|
+
return JSONResponse(
|
|
107
|
+
{"detail": "Reload XFlog to begin a local session."}, status_code=401
|
|
108
|
+
)
|
|
109
|
+
if protected and request.method not in {"GET", "HEAD"}:
|
|
110
|
+
if request.headers.get("origin") != config.origin or not secrets.compare_digest(
|
|
111
|
+
request.headers.get("x-xflog-csrf", ""), current["csrf"]
|
|
112
|
+
):
|
|
113
|
+
return JSONResponse(
|
|
114
|
+
{"detail": "Request could not be verified. Reload XFlog."},
|
|
115
|
+
status_code=403,
|
|
116
|
+
)
|
|
117
|
+
request.state.session = session
|
|
118
|
+
response = await call_next(request)
|
|
119
|
+
if fresh:
|
|
120
|
+
response.set_cookie(
|
|
121
|
+
"xflog_session",
|
|
122
|
+
session,
|
|
123
|
+
httponly=True,
|
|
124
|
+
secure=config.secure,
|
|
125
|
+
samesite="lax",
|
|
126
|
+
max_age=86400,
|
|
127
|
+
)
|
|
128
|
+
response.headers.update(
|
|
129
|
+
{
|
|
130
|
+
"Cache-Control": "no-store",
|
|
131
|
+
"Referrer-Policy": "no-referrer",
|
|
132
|
+
"X-Content-Type-Options": "nosniff",
|
|
133
|
+
"X-Frame-Options": "DENY",
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
return response
|
|
137
|
+
|
|
138
|
+
@app.exception_handler(SetupError)
|
|
139
|
+
@app.exception_handler(ProviderError)
|
|
140
|
+
async def known_error(request, error):
|
|
141
|
+
return JSONResponse({"detail": str(error)}, status_code=409)
|
|
142
|
+
|
|
143
|
+
@app.exception_handler(sqlite3.Error)
|
|
144
|
+
@app.exception_handler(OSError)
|
|
145
|
+
async def database_error(request, error):
|
|
146
|
+
return JSONResponse(
|
|
147
|
+
{"detail": "Local database unavailable. Check disk space and file access."},
|
|
148
|
+
status_code=503,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
@app.exception_handler(httpx.HTTPError)
|
|
152
|
+
async def network_error(request, error):
|
|
153
|
+
return JSONResponse(
|
|
154
|
+
{"detail": "Could not reach X. Check your connection and retry."},
|
|
155
|
+
status_code=502,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
@app.get("/api/status")
|
|
159
|
+
async def status(request: Request):
|
|
160
|
+
account = await store.setting("account")
|
|
161
|
+
selection = await store.setting("selection", DEFAULT_SELECTION)
|
|
162
|
+
return {
|
|
163
|
+
"account": account,
|
|
164
|
+
"connected": collector.connected,
|
|
165
|
+
"state": collector.state,
|
|
166
|
+
"message": collector.message,
|
|
167
|
+
"selection": selection,
|
|
168
|
+
"missing_settings": runtime.config.missing_settings(selection),
|
|
169
|
+
"setup_message": runtime.identity_error or runtime.config.setup_message(selection),
|
|
170
|
+
"environment_file": config.environment_file,
|
|
171
|
+
"preference_warning": collector.preference_warning,
|
|
172
|
+
"profile_warning": await store.setting("profile_warning", "")
|
|
173
|
+
if selection.get("profile_names")
|
|
174
|
+
else "",
|
|
175
|
+
"tracking": await store.setting("tracking", False),
|
|
176
|
+
"counts": await store.summary(account["id"]) if account else {},
|
|
177
|
+
"gaps": await store.gaps(account["id"]) if account else [],
|
|
178
|
+
"cleanup_warning": await store.setting("cleanup_warning", ""),
|
|
179
|
+
"csrf": sessions[request.state.session]["csrf"],
|
|
180
|
+
"notification_sequence": collector.notifications,
|
|
181
|
+
"timeline_revision": await timeline.revision(account["id"]) if account else "0:0",
|
|
182
|
+
"audience_groups": audience_groups.catalog(await store.setting("audience_groups", {})),
|
|
183
|
+
"follow_actions": await follow_actions.status(),
|
|
184
|
+
"interaction_types": catalog(),
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@app.get("/api/activity-summary")
|
|
188
|
+
async def activity_summary(period: str = "24h", subject: str = "followers", demo: bool = False):
|
|
189
|
+
if period not in PERIODS or subject not in SUBJECT_TYPES:
|
|
190
|
+
raise HTTPException(422, "Invalid activity period or audience.")
|
|
191
|
+
if demo:
|
|
192
|
+
return demo_activity(period, subject)
|
|
193
|
+
window = activity_window(period)
|
|
194
|
+
account = await store.setting("account")
|
|
195
|
+
counts = await store.activity_counts(account["id"], window, subject) if account else {}
|
|
196
|
+
return {**readings(counts, window, subject), "synthetic": False}
|
|
197
|
+
|
|
198
|
+
@app.get("/api/timeline")
|
|
199
|
+
async def timeline_history(kind: str = "all", subject: str = "followers", before: str = "0"):
|
|
200
|
+
try:
|
|
201
|
+
decode_cursor(before)
|
|
202
|
+
except ValueError:
|
|
203
|
+
raise HTTPException(422, "Invalid timeline cursor.") from None
|
|
204
|
+
if not valid_filters(kind, subject, 0):
|
|
205
|
+
raise HTTPException(422, "Invalid timeline filter.")
|
|
206
|
+
account = await store.setting("account")
|
|
207
|
+
if not account:
|
|
208
|
+
return {"events": [], "next": None}
|
|
209
|
+
result = await timeline.history(
|
|
210
|
+
account["id"], {"kind": kind, "subject": subject, "before": before}
|
|
211
|
+
)
|
|
212
|
+
if await profile_names.ensure(result["events"]):
|
|
213
|
+
result = await timeline.history(
|
|
214
|
+
account["id"], {"kind": kind, "subject": subject, "before": before}
|
|
215
|
+
)
|
|
216
|
+
groups = await store.setting("audience_groups", {})
|
|
217
|
+
result["events"] = await audience_groups.decorate_history(
|
|
218
|
+
result["events"], groups, timeline.encounter_context
|
|
219
|
+
)
|
|
220
|
+
return result
|
|
221
|
+
|
|
222
|
+
@app.get("/api/events")
|
|
223
|
+
async def history(kind: str = "all", subject: str = "followers", before: int = 0):
|
|
224
|
+
if not valid_filters(kind, subject, before):
|
|
225
|
+
raise HTTPException(422, "Invalid history filter.")
|
|
226
|
+
account = await store.setting("account")
|
|
227
|
+
if not account:
|
|
228
|
+
return {"events": [], "next": None}
|
|
229
|
+
result = await store.history(
|
|
230
|
+
account["id"], {"kind": kind, "subject": subject, "before": before}
|
|
231
|
+
)
|
|
232
|
+
groups = await store.setting("audience_groups", {})
|
|
233
|
+
result["events"] = await audience_groups.decorate_history(
|
|
234
|
+
result["events"], groups, store.encounter_context
|
|
235
|
+
)
|
|
236
|
+
return result
|
|
237
|
+
|
|
238
|
+
@app.get("/api/demo")
|
|
239
|
+
async def demo(kind: str = "all", subject: str = "followers", before: int = 0):
|
|
240
|
+
if not valid_filters(kind, subject, before):
|
|
241
|
+
raise HTTPException(422, "Invalid demo filter.")
|
|
242
|
+
result = demo_history({"kind": kind, "subject": subject, "before": before})
|
|
243
|
+
groups = await store.setting("audience_groups", {})
|
|
244
|
+
result["events"] = await audience_groups.decorate_history(
|
|
245
|
+
result["events"], groups, demo_encounter_context
|
|
246
|
+
)
|
|
247
|
+
return result
|
|
248
|
+
|
|
249
|
+
@app.post("/api/audience-groups")
|
|
250
|
+
async def save_audience_groups(settings: AudiencePreferences):
|
|
251
|
+
if settings.enabled.keys() - audience_groups.MODULES.keys():
|
|
252
|
+
raise HTTPException(422, "Unknown audience group.")
|
|
253
|
+
async with controls:
|
|
254
|
+
previous = audience_groups.preferences(await store.setting("audience_groups", {}))
|
|
255
|
+
enabled = {**previous, **settings.enabled}
|
|
256
|
+
await store.save_setting("audience_groups", enabled)
|
|
257
|
+
return {"audience_groups": audience_groups.catalog(enabled)}
|
|
258
|
+
|
|
259
|
+
@app.post("/api/preferences")
|
|
260
|
+
async def preferences(selection: Selection):
|
|
261
|
+
async with interactions.lock:
|
|
262
|
+
previous = await store.setting("selection", DEFAULT_SELECTION)
|
|
263
|
+
follow_setting = (
|
|
264
|
+
selection.follow_actions if "follow_actions" in selection.model_fields_set else None
|
|
265
|
+
)
|
|
266
|
+
if follow_setting is not None:
|
|
267
|
+
follow_actions.validate_setting(follow_setting)
|
|
268
|
+
values = selection.model_dump(exclude={"follow_actions", "interactions"})
|
|
269
|
+
if selection.interactions is not None:
|
|
270
|
+
if selection.interactions.keys() - TYPES.keys():
|
|
271
|
+
raise HTTPException(422, "Unknown interaction type.")
|
|
272
|
+
values["interactions"] = selection.interactions
|
|
273
|
+
else:
|
|
274
|
+
if "interactions" in previous:
|
|
275
|
+
values["interactions"] = previous["interactions"]
|
|
276
|
+
interactions.validate_selection(values)
|
|
277
|
+
result = await collector.save_preferences(values)
|
|
278
|
+
if result["saved"] and selection.profile_names and not previous.get("profile_names"):
|
|
279
|
+
await profile_names.retry_unresolved()
|
|
280
|
+
if result["saved"] and follow_setting is not None:
|
|
281
|
+
await follow_actions.configure(follow_setting)
|
|
282
|
+
return result
|
|
283
|
+
|
|
284
|
+
@app.post("/api/follow-actions/relationship")
|
|
285
|
+
async def follow_relationship(target: FollowTarget):
|
|
286
|
+
if target.demo:
|
|
287
|
+
raise SetupError("Follow actions are unavailable in the offline demo.")
|
|
288
|
+
return await follow_actions.relationship(target.event_id)
|
|
289
|
+
|
|
290
|
+
@app.post("/api/follow-actions")
|
|
291
|
+
async def change_follow(target: FollowChange):
|
|
292
|
+
if target.demo:
|
|
293
|
+
raise SetupError("Follow actions are unavailable in the offline demo.")
|
|
294
|
+
return await follow_actions.change(target.event_id, target.following)
|
|
295
|
+
|
|
296
|
+
@app.get("/api/interactions")
|
|
297
|
+
async def person_interactions(event_id: str, before: int = 0, demo: bool = False):
|
|
298
|
+
if not 0 <= before <= 9223372036854775807 or not 1 <= len(event_id) <= 200:
|
|
299
|
+
raise HTTPException(422, "Invalid interaction query.")
|
|
300
|
+
if demo:
|
|
301
|
+
return {"interactions": [], "next": None}
|
|
302
|
+
return await interactions.history(event_id, before)
|
|
303
|
+
|
|
304
|
+
@app.post("/api/interactions/thread")
|
|
305
|
+
async def thread_snapshot(body: ThreadRequest):
|
|
306
|
+
if body.demo:
|
|
307
|
+
raise SetupError("Thread loading is unavailable in the offline demo.")
|
|
308
|
+
options = ThreadOptions(**body.model_dump(exclude={"event_id", "demo"}))
|
|
309
|
+
return await interactions.thread(body.event_id, options)
|
|
310
|
+
|
|
311
|
+
@app.post("/api/start")
|
|
312
|
+
async def start(body: StartRequest):
|
|
313
|
+
if not body.accepted_costs:
|
|
314
|
+
raise HTTPException(422, "Review billing and explicitly accept before starting.")
|
|
315
|
+
async with controls:
|
|
316
|
+
await collector.start()
|
|
317
|
+
return {"started": True}
|
|
318
|
+
|
|
319
|
+
@app.post("/api/stop")
|
|
320
|
+
async def stop():
|
|
321
|
+
async with controls:
|
|
322
|
+
await collector.stop()
|
|
323
|
+
return {"stopped": True}
|
|
324
|
+
|
|
325
|
+
app.mount("/static/xf", StaticFiles(directory=ASSETS), name="assets")
|
|
326
|
+
|
|
327
|
+
@app.get("/healthz")
|
|
328
|
+
async def health():
|
|
329
|
+
return {"ok": True}
|
|
330
|
+
|
|
331
|
+
if mount_ui:
|
|
332
|
+
app = mount_browser_ui(app, config)
|
|
333
|
+
else:
|
|
334
|
+
|
|
335
|
+
@app.get("/")
|
|
336
|
+
async def root():
|
|
337
|
+
return {"app": "XFlog"}
|
|
338
|
+
|
|
339
|
+
return app
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
|
|
5
|
+
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|