fix(settings): add DingTalk spaces and render the real login QR
Address two gaps in the first DingTalk-session UI: - add an explicit admin-only '+ 新增钉钉知识库' action on the data-source panel; it accepts an alidocs space URL, resolves the live name/root through the authenticated sidecar, writes the inventory root atomically, upserts a deterministic source connection, and enqueues its first catalog refresh - read DingTalk's real QR canvas pixels rather than taking a DOM screenshot; select by dark-pixel content, composite onto a white quiet zone, and render at 320x320 so the dialog contains a large complete code, not a page thumbnail The live refresh path resolves registered roots from the connection locator, while existing name-based DingTalk sources remain compatible.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRegisterDingtalkSpaceConnectionIDIsStableAndCompatibleWithImporter(t *testing.T) {
|
||||
input := RegisterDingtalkSpaceInput{
|
||||
RootKey: "atom", Name: "ATOM", SpaceID: "9JOGOQneRgkneX4Q",
|
||||
RootID: "root-atom", Now: time.Now(),
|
||||
}
|
||||
first := input.ConnectionID()
|
||||
second := input.ConnectionID()
|
||||
if first != second || len(first) != 35 || first[:3] != "sc-" {
|
||||
t.Fatalf("unstable connection id: %q / %q", first, second)
|
||||
}
|
||||
if err := input.validate(); err != nil {
|
||||
t.Fatalf("valid registration rejected: %v", err)
|
||||
}
|
||||
input.SpaceID = "../bad"
|
||||
if err := input.validate(); err == nil {
|
||||
t.Fatal("hostile space id accepted")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user