支持免登录游客聊天并隔离历史与附件
This commit is contained in:
+16
-3
@@ -111,17 +111,30 @@ install -m 644 "$release/site.htpasswd" "$auth"
|
||||
install -m 644 "$release/site.conf" "$site"
|
||||
nginx -t
|
||||
nginx -s reload
|
||||
for path in / /api/export_chat /api/get_history; do
|
||||
for check in /:200 /admin/dashboard:401 /api/export_chat:401 /api/get_history:401 /api/human/queue:401; do
|
||||
path=${check%:*}
|
||||
expected=${check##*:}
|
||||
code=''
|
||||
# A successful reload signal precedes the new workers accepting connections.
|
||||
for attempt in {1..10}; do
|
||||
if code=$(curl --silent --connect-timeout 3 --max-time 8 --resolve "$CHAT_DOMAIN:443:127.0.0.1" -o /dev/null -w '%{http_code}' "https://$CHAT_DOMAIN$path"); then
|
||||
[[ "$code" != 401 ]] || break
|
||||
[[ "$code" != "$expected" ]] || break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
[[ "$code" == 401 ]] || { echo 'Gray access protection verification failed.' >&2; false; }
|
||||
[[ "$code" == "$expected" ]] || { echo 'Guest/staff access verification failed.' >&2; false; }
|
||||
done
|
||||
visitor_cookie=$(mktemp "$release/.visitor-smoke.XXXXXX")
|
||||
trap 'rm -f -- "$visitor_cookie"' EXIT
|
||||
code=$(curl --silent --show-error --max-time 10 --resolve "$CHAT_DOMAIN:443:127.0.0.1" \
|
||||
-c "$visitor_cookie" -o /dev/null -w '%{http_code}' -H 'Content-Type: application/json' \
|
||||
-d '{}' "https://$CHAT_DOMAIN/api/visitor/session")
|
||||
[[ "$code" == 200 ]] || { echo 'Guest session bootstrap verification failed.' >&2; false; }
|
||||
code=$(curl --silent --show-error --max-time 10 --resolve "$CHAT_DOMAIN:443:127.0.0.1" \
|
||||
-b "$visitor_cookie" -o /dev/null -w '%{http_code}' "https://$CHAT_DOMAIN/api/get_history")
|
||||
[[ "$code" == 200 ]] || { echo 'Guest history verification failed.' >&2; false; }
|
||||
rm -f -- "$visitor_cookie"
|
||||
trap - EXIT
|
||||
printf '%s\n' "$release" > "$root/.current-release.new"
|
||||
mv -f "$root/.current-release.new" "$root/current-release"
|
||||
trap - ERR
|
||||
|
||||
Reference in New Issue
Block a user