Manage T5DE rooms from the client; the AP+ badge on avatar cards
CI / build (push) Successful in 28s
CI / build (push) Successful in 28s
Chat Rooms > Manage (the t5de-room-manage patch) lists the person's T5DE rooms (room_management_info.php?t5de=1) and saves them from IMVU's room dialog (room_management.php: create with t5de=1, edit and delete naming a hosted room) as hub calls: the room, its moderators by name, and a picture from the person's IMVU gallery, uploaded to the hub. The hub's refusals show in the dialog (hub.Error keeps their message). Avatar cards get show_ap_plus again, which IMVU stopped sending, from the person's public IMVU profile (is_ap_plus). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
6aac769246
commit
8daf91ede3
7 files changed
+608
-2
No files matched your search
@@ -0,0 +1,50 @@
|
||||
package cards
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.t5de.dev/t5de/t5de-proxy/internal/proxy"
|
||||
)
|
||||
|
||||
func TestAPPlusBadge(t *testing.T) {
|
||||
asked := 0
|
||||
imvu := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
asked++
|
||||
id := strings.TrimPrefix(r.URL.Path, "/user/user-")
|
||||
fmt.Fprintf(w, `{"denormalized": {"https://api.imvu.com/user/user-%s": {"data": {"is_ap_plus": %v}}}}`, id, id == "5")
|
||||
}))
|
||||
defer imvu.Close()
|
||||
c := &Cards{Base: imvu.URL}
|
||||
card := func(cid, body string) string {
|
||||
t.Helper()
|
||||
u, _ := url.Parse("https://client-dynamic.imvu.com/api/avatarcard.php?cid=" + cid + "&viewer_cid=1")
|
||||
x := &proxy.Exchange{URL: u}
|
||||
if err := c.Intercept(x); err != nil || x.ModifyResponse == nil {
|
||||
t.Fatalf("not intercepted: %v", err)
|
||||
}
|
||||
out, err := x.ModifyResponse(&http.Response{StatusCode: 200}, []byte(body))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return string(out)
|
||||
}
|
||||
if out := card("5", `{"avatarname": "Ann", "show_ap": 1}`); !strings.Contains(out, `"show_ap_plus":1`) || !strings.Contains(out, `"avatarname":"Ann"`) {
|
||||
t.Fatalf("AP+ card %s", out)
|
||||
}
|
||||
if out := card("6", `{"avatarname": "Bo"}`); strings.Contains(out, "show_ap_plus") {
|
||||
t.Fatalf("no AP+ %s", out)
|
||||
}
|
||||
card("5", `{}`)
|
||||
if asked != 2 {
|
||||
t.Fatalf("IMVU asked %d times (kept for a while)", asked)
|
||||
}
|
||||
// Already set by IMVU: left alone, IMVU not asked.
|
||||
if out := card("7", `{"show_ap_plus": true}`); out != `{"show_ap_plus": true}` || asked != 2 {
|
||||
t.Fatalf("set already %s (%d)", out, asked)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user