refactor: 项目更名 WeKnora → Academy
Build & Publish (dsh-academy) / End-to-end inside dsh (latest, advisory) (push) Skipped
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Frontend / Docker multi-stage image (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-academy) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-academy) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-academy) / Publish to npm (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Helm / chart (push) Canceled after 0s

- 全量替换代码/配置/文档中的项目名(保留上游 GitHub 链接、weixin 文档域名、Docker Hub 镜像名)
- 重命名 32 个含项目名的文件/目录;Go module 路径改为 academy(含 client/cli 子模块)
- docreader proto 描述符采用等长替换,保持序列化字节布局有效
- Dockerfile.app 构建网络修复: browserskill 离线产物通道、PyPI/apt 国内镜像
- 运行验证: go build ✓ docker compose up ✓ 健康检查 ✓
This commit is contained in:
runny committed 2026-11-13 20:52:51 +08:00
1 parent 9097ee699d
commit 9058149576
3136 files changed
+18018 -18004

No files matched your search

+1 -1
View File
@@ -110,7 +110,7 @@ const (
ChatTypeGroup ChatType = "group"
)
// ReplyMessage is what WeKnora sends back to the IM platform.
// ReplyMessage is what Academy sends back to the IM platform.
type ReplyMessage struct {
// Content is the text content (Markdown).
Content string
+8 -8
View File
@@ -5,14 +5,14 @@ import (
"net/http/httptest"
"testing"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/im/dingtalk"
"github.com/Tencent/WeKnora/internal/im/feishu"
"github.com/Tencent/WeKnora/internal/im/mattermost"
"github.com/Tencent/WeKnora/internal/im/qqbot"
"github.com/Tencent/WeKnora/internal/im/slack"
"github.com/Tencent/WeKnora/internal/im/telegram"
"github.com/Tencent/WeKnora/internal/im/yunzhijia"
"academy/internal/im"
"academy/internal/im/dingtalk"
"academy/internal/im/feishu"
"academy/internal/im/mattermost"
"academy/internal/im/qqbot"
"academy/internal/im/slack"
"academy/internal/im/telegram"
"academy/internal/im/yunzhijia"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -5,8 +5,8 @@ import (
"errors"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"github.com/stretchr/testify/require"
)
+1 -1
View File
@@ -3,7 +3,7 @@ package im
import (
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// Files uploaded through an IM channel are tagged with a knowledge Channel.
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"fmt"
"strings"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types/interfaces"
)
// InfoCommand implements /info.
+3 -3
View File
@@ -5,9 +5,9 @@ import (
"fmt"
"strings"
"github.com/Tencent/WeKnora/internal/agent/tools"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/agent/tools"
"academy/internal/logger"
"academy/internal/types/interfaces"
)
const (
+1 -1
View File
@@ -3,7 +3,7 @@ package im
import (
"context"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
// CommandAction represents a service-level side effect that a command requests.
+11 -11
View File
@@ -6,7 +6,7 @@ import (
"strings"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -115,8 +115,8 @@ func TestFindIncompleteXMLTag(t *testing.T) {
func TestResolveIMFileServiceForPath_LocalSchemeDespiteCOSDefault(t *testing.T) {
t.Setenv("SYSTEM_SIGNING_KEY", "")
t.Setenv("SYSTEM_AES_KEY", "weknora-test-aes-key-32bytes!!!")
t.Setenv("APP_EXTERNAL_URL", "https://weknora.example.com")
t.Setenv("SYSTEM_AES_KEY", "academy-test-aes-key-32bytes!!!")
t.Setenv("APP_EXTERNAL_URL", "https://academy.example.com")
tenant := &types.Tenant{
StorageEngineConfig: &types.StorageEngineConfig{
@@ -138,8 +138,8 @@ func TestResolveIMFileServiceForPath_LocalSchemeDespiteCOSDefault(t *testing.T)
func TestRewriteStorageURLs_LocalUsesPresignedAPI(t *testing.T) {
t.Setenv("SYSTEM_SIGNING_KEY", "")
t.Setenv("SYSTEM_AES_KEY", "weknora-test-aes-key-32bytes!!!")
t.Setenv("APP_EXTERNAL_URL", "https://weknora.example.com")
t.Setenv("SYSTEM_AES_KEY", "academy-test-aes-key-32bytes!!!")
t.Setenv("APP_EXTERNAL_URL", "https://academy.example.com")
tenant := &types.Tenant{
StorageEngineConfig: &types.StorageEngineConfig{
@@ -170,11 +170,11 @@ func TestRewriteStorageURLs_COSPathNotSignedAsLocalKey(t *testing.T) {
SecretKey: "key",
BucketName: "test-bucket",
Region: "ap-shanghai",
PathPrefix: "weknora",
PathPrefix: "academy",
},
},
}
path := "cos://test-bucket/ap-shanghai/weknora/10000/exports/abc.png"
path := "cos://test-bucket/ap-shanghai/academy/10000/exports/abc.png"
svc := resolveIMFileServiceForPath(tenant, path, nil)
require.NotNil(t, svc)
@@ -351,8 +351,8 @@ func TestSimulateIMStreamFlush_BareProviderURLStillHeld(t *testing.T) {
func TestCleanIMContent_AfterStreamReassembly(t *testing.T) {
t.Setenv("SYSTEM_SIGNING_KEY", "")
t.Setenv("SYSTEM_AES_KEY", "weknora-test-aes-key-32bytes!!!")
t.Setenv("APP_EXTERNAL_URL", "https://weknora.example.com")
t.Setenv("SYSTEM_AES_KEY", "academy-test-aes-key-32bytes!!!")
t.Setenv("APP_EXTERNAL_URL", "https://academy.example.com")
tenant := &types.Tenant{
StorageEngineConfig: &types.StorageEngineConfig{
@@ -401,8 +401,8 @@ func TestSimulateIMStreamFlush_BracketInAltMiddleImage(t *testing.T) {
func TestRewriteStorageURLs_MultipleImagesInOneChunk(t *testing.T) {
t.Setenv("SYSTEM_SIGNING_KEY", "")
t.Setenv("SYSTEM_AES_KEY", "weknora-test-aes-key-32bytes!!!")
t.Setenv("APP_EXTERNAL_URL", "https://weknora.example.com")
t.Setenv("SYSTEM_AES_KEY", "academy-test-aes-key-32bytes!!!")
t.Setenv("APP_EXTERNAL_URL", "https://academy.example.com")
tenant := &types.Tenant{
StorageEngineConfig: &types.StorageEngineConfig{DefaultProvider: "cos"},
+4 -4
View File
@@ -17,9 +17,9 @@ import (
"github.com/google/uuid"
"github.com/open-dingtalk/dingtalk-stream-sdk-go/chatbot"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
"academy/internal/logger"
secutils "academy/internal/utils"
)
// httpClient is a shared HTTP client with a reasonable timeout for DingTalk API calls.
@@ -225,7 +225,7 @@ func parseAudioContent(msgtype string, content json.RawMessage) (string, bool) {
return text, true
}
// parseFileContent maps a DingTalk msgtype + content object to WeKnora's file
// parseFileContent maps a DingTalk msgtype + content object to Academy's file
// message fields. Returns ok=false for non-file/picture message types so the
// caller keeps its text handling. Picture messages have no fileName; the IM
// service appends an extension after download.
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"github.com/open-dingtalk/dingtalk-stream-sdk-go/chatbot"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
// Compile-time check: the adapter must implement FileDownloader so the IM
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
func useTestHTTPClient(t *testing.T) {
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"context"
"fmt"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
// NewFactory returns an im.AdapterFactory for DingTalk channels.
+2 -2
View File
@@ -6,8 +6,8 @@ import (
"github.com/open-dingtalk/dingtalk-stream-sdk-go/chatbot"
dtsdk "github.com/open-dingtalk/dingtalk-stream-sdk-go/client"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
)
// MessageHandler is called when an IM message is received via stream connection.
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"strings"
"testing"
"github.com/Tencent/WeKnora/internal/im"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
secutils "academy/internal/utils"
"github.com/stretchr/testify/require"
)
+6 -6
View File
@@ -1,4 +1,4 @@
// Package feishu implements the Feishu (飞书) IM adapter for WeKnora, and with
// Package feishu implements the Feishu (飞书) IM adapter for Academy, and with
// it the Lark adapter: Feishu and Lark are the same product on two isolated
// clouds (open.feishu.cn and open.larksuite.com) sharing one API surface, so a
// single implementation serves both. A Region picks the cloud — see region.go.
@@ -31,9 +31,9 @@ import (
"time"
"unicode/utf8"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
"academy/internal/logger"
"academy/internal/utils"
"github.com/gin-gonic/gin"
larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1"
)
@@ -917,7 +917,7 @@ func buildStreamingCardJSON(region Region) string {
},
"header": map[string]interface{}{
"template": "blue",
"title": map[string]string{"tag": "plain_text", "content": "WeKnora"},
"title": map[string]string{"tag": "plain_text", "content": "Academy"},
},
"body": map[string]interface{}{
"elements": []map[string]interface{}{
@@ -1169,7 +1169,7 @@ func (a *Adapter) cardkitUpdateElement(ctx context.Context, accessToken, cardID,
// Feishu card markdown images use the syntax ![hover_text](image_key) where the
// value inside the parentheses MUST be an image_key obtained from the Feishu
// "upload image" API. External HTTP/COS URLs are rejected with
// code=200570 "card contains invalid image keys". WeKnora's content pipeline
// code=200570 "card contains invalid image keys". Academy's content pipeline
// rewrites provider:// storage URLs to signed HTTP URLs, so by the time content
// reaches the card we must download each referenced image and re-upload it to
// Feishu to obtain a usable image_key.
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"strings"
"testing"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
"github.com/gin-gonic/gin"
)
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
)
// NewFactory returns an im.AdapterFactory for channels on the given region's
+2 -2
View File
@@ -6,8 +6,8 @@ import (
"fmt"
"strings"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
"github.com/larksuite/oapi-sdk-go/v3/event/dispatcher"
larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1"
larkws "github.com/larksuite/oapi-sdk-go/v3/ws"
+2 -2
View File
@@ -3,7 +3,7 @@ package feishu
import (
"testing"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1"
)
@@ -42,7 +42,7 @@ func TestConvertEventKeepsGroupMessageThatMentionsBot(t *testing.T) {
Mentions: []*larkim.MentionEvent{{
Key: stringPtr("@_user_1"),
MentionedType: stringPtr("bot"),
Name: stringPtr("WeKnora"),
Name: stringPtr("Academy"),
Id: &larkim.UserId{OpenId: stringPtr("ou_bot")},
}},
},
+1 -1
View File
@@ -1,6 +1,6 @@
package feishu
import "github.com/Tencent/WeKnora/internal/im"
import "academy/internal/im"
// Open Platform API origins. Feishu and Lark are the same product deployed on
// two isolated clouds; the API surface is identical, only the host differs.
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"strings"
"testing"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
// The two regions must stay distinct in every dimension that reaches the
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
func useTestHTTPClient(t *testing.T) {
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"time"
"unicode/utf8"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
func registerTestStream(t *testing.T, id string, state *feishuStreamState) {
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"testing"
"unicode/utf8"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
type attachmentTestAdapter struct {
+3 -3
View File
@@ -8,9 +8,9 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/event"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/event"
"academy/internal/types"
"academy/internal/types/interfaces"
)
type fullOutputOrder struct {
+7 -7
View File
@@ -6,11 +6,11 @@ import (
"strings"
"testing"
"github.com/Tencent/WeKnora/internal/application/repository"
appsvc "github.com/Tencent/WeKnora/internal/application/service"
filesvc "github.com/Tencent/WeKnora/internal/application/service/file"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/application/repository"
appsvc "academy/internal/application/service"
filesvc "academy/internal/application/service/file"
"academy/internal/types"
"academy/internal/types/interfaces"
"github.com/stretchr/testify/require"
)
@@ -27,7 +27,7 @@ func configureIMGlobalOSS(t *testing.T, f *imResourceStorageFixture) interfaces.
f.catalog = appsvc.NewResourceCatalogWithStorage(repository.NewResourceRepository(f.db), repo)
f.storage = appsvc.NewStorageBackendService(repo, f.db, f.catalog)
driver, err := filesvc.NewOssFileService(f.baseURL, "cn-hangzhou", "global-key", "test-secret",
"global-artifacts", "weknora/")
"global-artifacts", "academy/")
require.NoError(t, err)
f.global = filesvc.NewGlobalResourceCatalogFileService(driver, f.catalog)
return driver
@@ -72,7 +72,7 @@ func TestIMGlobalResourcesKeepTheirActualStorage(t *testing.T) {
require.NotContains(t, out, "resource://")
u, err := url.Parse(strings.TrimSuffix(strings.TrimPrefix(out, "![report]("), ")"))
require.NoError(t, err)
require.Contains(t, u.Path, "global-artifacts/weknora/7/exports/")
require.Contains(t, u.Path, "global-artifacts/academy/7/exports/")
require.Contains(t, u.Query().Get("x-oss-credential"), "global-key/")
require.NotEmpty(t, u.Query().Get("x-oss-signature"))
}
+2 -2
View File
@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
func TestWithIMIdentity(t *testing.T) {
@@ -55,7 +55,7 @@ func TestWithIMIdentity(t *testing.T) {
}
func TestWithIMIdentityUsesDeploymentDefaultWithoutChannelLocale(t *testing.T) {
t.Setenv("WEKNORA_LANGUAGE", "ko-KR")
t.Setenv("ACADEMY_LANGUAGE", "ko-KR")
ctx := context.WithValue(context.Background(), types.LanguageContextKey, "en-US")
ctx = withIMIdentity(ctx, &IMChannel{ID: "channel-1", TenantID: 42}, nil)
+1 -1
View File
@@ -13,7 +13,7 @@ func TestIMImageConfigWarning(t *testing.T) {
assert.Empty(t, imImageConfigWarning(0, ""))
})
t.Run("external URL set -> silent", func(t *testing.T) {
assert.Empty(t, imImageConfigWarning(3, "https://weknora.example.com"))
assert.Empty(t, imImageConfigWarning(3, "https://academy.example.com"))
})
t.Run("external URL whitespace-only -> warns", func(t *testing.T) {
assert.NotEmpty(t, imImageConfigWarning(1, " "))
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"mime/multipart"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
+2 -2
View File
@@ -11,8 +11,8 @@ import (
"github.com/gin-gonic/gin"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
)
// Compile-time checks.
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"net/http/httptest"
"testing"
secutils "github.com/Tencent/WeKnora/internal/utils"
secutils "academy/internal/utils"
)
func withMattermostSSRFWhitelist(t *testing.T, whitelist string) {
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"time"
"unicode/utf8"
secutils "github.com/Tencent/WeKnora/internal/utils"
secutils "academy/internal/utils"
)
// Client calls Mattermost REST API v4.
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"context"
"fmt"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
// NewFactory returns an im.AdapterFactory for Mattermost channels.
+3 -3
View File
@@ -7,9 +7,9 @@ import (
"testing/synctest"
"time"
"github.com/Tencent/WeKnora/internal/event"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/event"
"academy/internal/types"
"academy/internal/types/interfaces"
)
type exitSessionService struct {
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"sync/atomic"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/logger"
"academy/internal/types"
"github.com/redis/go-redis/v9"
)
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
var _ im.Adapter = (*Adapter)(nil)
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"encoding/json"
"testing"
"github.com/Tencent/WeKnora/internal/im"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
secutils "academy/internal/utils"
)
func withQQBotSSRFWhitelist(t *testing.T, whitelist string) {
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"sync"
"time"
secutils "github.com/Tencent/WeKnora/internal/utils"
secutils "academy/internal/utils"
)
type Client struct {
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
)
func NewFactory() im.AdapterFactory {
+3 -3
View File
@@ -7,9 +7,9 @@ import (
"sync"
"time"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
"academy/internal/logger"
secutils "academy/internal/utils"
ws "github.com/gorilla/websocket"
)
+4 -4
View File
@@ -4,10 +4,10 @@ import (
"context"
"slices"
"github.com/Tencent/WeKnora/internal/application/access"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/application/access"
"academy/internal/types"
"academy/internal/types/interfaces"
secutils "academy/internal/utils"
)
// authorizeOutboundResource checks actual file ownership and live KB sharing.
+3 -3
View File
@@ -5,8 +5,8 @@ import (
"errors"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
"github.com/stretchr/testify/require"
)
@@ -30,7 +30,7 @@ func TestIMResourceAccessFailsClosed(t *testing.T) {
"organization deleted", "catalog failure", "sharing failure", "missing identity",
"other selected KB", "no KBs", "explicit KB restriction",
}
for _, externalURL := range []string{"", "https://weknora.example"} {
for _, externalURL := range []string{"", "https://academy.example"} {
for _, scenario := range cases {
t.Run(scenario+externalURL, func(t *testing.T) {
f := newIMResourceStorageFixture(t)
+8 -8
View File
@@ -13,12 +13,12 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/application/repository"
appsvc "github.com/Tencent/WeKnora/internal/application/service"
filesvc "github.com/Tencent/WeKnora/internal/application/service/file"
"github.com/Tencent/WeKnora/internal/event"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/application/repository"
appsvc "academy/internal/application/service"
filesvc "academy/internal/application/service/file"
"academy/internal/event"
"academy/internal/types"
"academy/internal/types/interfaces"
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
@@ -222,9 +222,9 @@ func TestIMResourceStoragePreservesShortLinksAndRejectsUnavailableInstances(t *t
s, _, _, _ := newFullOutputHarness(f.answer)
f.wire(s)
ctx := f.context()
t.Setenv("APP_EXTERNAL_URL", "https://weknora.example")
t.Setenv("APP_EXTERNAL_URL", "https://academy.example")
out := cleanIMContent(ctx, f.answer, s.newOutboundFileServiceResolver(f.tenant, nil, nil))
require.Equal(t, 3, strings.Count(out, "https://weknora.example/r/"))
require.Equal(t, 3, strings.Count(out, "https://academy.example/r/"))
require.NotContains(t, out, "resource://")
t.Setenv("APP_EXTERNAL_URL", "")
+21 -21
View File
@@ -21,17 +21,17 @@ import (
"time"
"unicode/utf8"
agenttools "github.com/Tencent/WeKnora/internal/agent/tools"
"github.com/Tencent/WeKnora/internal/config"
apperrors "github.com/Tencent/WeKnora/internal/errors"
"github.com/Tencent/WeKnora/internal/event"
"github.com/Tencent/WeKnora/internal/infrastructure/docparser"
"github.com/Tencent/WeKnora/internal/logger"
mcppkg "github.com/Tencent/WeKnora/internal/mcp"
"github.com/Tencent/WeKnora/internal/ratelimit"
"github.com/Tencent/WeKnora/internal/storageurl"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
agenttools "academy/internal/agent/tools"
"academy/internal/config"
apperrors "academy/internal/errors"
"academy/internal/event"
"academy/internal/infrastructure/docparser"
"academy/internal/logger"
mcppkg "academy/internal/mcp"
"academy/internal/ratelimit"
"academy/internal/storageurl"
"academy/internal/types"
"academy/internal/types/interfaces"
"github.com/google/uuid"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
@@ -99,7 +99,7 @@ func stripImageXMLTags(s string) string {
}
// rewriteStorageURLs replaces all storage references in content with HTTP URLs
// so IM clients — which cannot attach WeKnora credentials to an image fetch —
// so IM clients — which cannot attach Academy credentials to an image fetch —
// can render them. See internal/storageurl for the shared implementation.
func rewriteStorageURLs(ctx context.Context, content string, resolver *storageurl.FileServiceResolver) string {
if resolver == nil {
@@ -298,9 +298,9 @@ type inflightEntry struct {
// Service orchestrates IM message handling:
// 1. Receives a unified IncomingMessage from an Adapter
// 2. Resolves or creates a WeKnora session for the IM channel
// 2. Resolves or creates a Academy session for the IM channel
// 3. Dispatches slash-commands (/help, /kb, /clear, etc.) without entering QA
// 4. Calls the WeKnora QA pipeline for normal messages
// 4. Calls the Academy QA pipeline for normal messages
// 5. Collects the streaming answer and sends it back via the Adapter
type Service struct {
db *gorm.DB
@@ -527,7 +527,7 @@ func (s *Service) buildIMMCPAuthNotice(ctx context.Context, services []imMCPAuth
if authURL != "" {
lines = append(lines, fmt.Sprintf("• %s:%s", name, authURL))
} else {
lines = append(lines, fmt.Sprintf("• %s(请在 WeKnora 管理后台完成 OAuth 授权)", name))
lines = append(lines, fmt.Sprintf("• %s(请在 Academy 管理后台完成 OAuth 授权)", name))
}
}
@@ -1796,7 +1796,7 @@ func (s *Service) HandleMessage(ctx context.Context, msg *IncomingMessage, chann
sessionCtx := context.WithValue(ctx, types.TenantInfoContextKey, tenant)
sessionCtx = withIMIdentity(sessionCtx, channel, msg)
// 2. Resolve or create a WeKnora session
// 2. Resolve or create a Academy session
channelSession, err := s.resolveSession(sessionCtx, msg, tenantID, agentID, channelID, channel.SessionMode)
if err != nil {
return fmt.Errorf("resolve session: %w", err)
@@ -1827,7 +1827,7 @@ func (s *Service) HandleMessage(ctx context.Context, msg *IncomingMessage, chann
return nil
}
// 4. Get the WeKnora session
// 4. Get the Academy session
session, err := s.sessionService.GetSession(sessionCtx, channelSession.SessionID)
if err != nil {
// The underlying session may have been deleted from the UI while the
@@ -2147,7 +2147,7 @@ func (s *Service) handleCommand(
switch result.Action {
case ActionClear:
// Soft-delete the current ChannelSession so the next IM message
// starts a completely fresh WeKnora session. Conversation history
// starts a completely fresh Academy session. Conversation history
// is keyed by session ID and rebuilt from DB on demand, so no
// separate cache invalidation step is needed.
if err := s.db.Model(&ChannelSession{}).
@@ -2241,7 +2241,7 @@ func (s *Service) sendStreamReply(ctx context.Context, msg *IncomingMessage, str
return nil
}
// isSessionNotFound reports whether err indicates the underlying WeKnora
// isSessionNotFound reports whether err indicates the underlying Academy
// session no longer exists. The session repository translates GORM's
// ErrRecordNotFound into apperrors.ErrSessionNotFound, so the application
// sentinel is what GetSession returns today; the GORM check is kept as a
@@ -2338,7 +2338,7 @@ func (s *Service) resolveUserSession(ctx context.Context, msg *IncomingMessage,
return nil, fmt.Errorf("query channel session: %w", result.Error)
}
// Create a new WeKnora session. Start untitled when there's text to summarise
// Create a new Academy session. Start untitled when there's text to summarise
// so it gets a content-based title after the first message (see HandleMessage);
// fall back to the IM identity title otherwise.
title := imInitialSessionTitle(msg, buildUserSessionTitle)
@@ -2979,7 +2979,7 @@ func (s *Service) fallbackNonStream(ctx context.Context, msg *IncomingMessage, s
})
}
// runQA executes the WeKnora QA pipeline and returns the full answer text.
// runQA executes the Academy QA pipeline and returns the full answer text.
func (s *Service) runQA(ctx context.Context, session *types.Session, query string, customAgent *types.CustomAgent, kbIDs []string, attachments types.MessageAttachments, imageURLs []string, userKey string, quote *QuotedMessage) (string, error) {
// Cancellable context (no hard deadline): each agent round has its own
// LLMCallTimeout. The context can still be cancelled by /stop.
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/types"
"academy/internal/types/interfaces"
)
type stubIMAgentService struct {
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/alicebob/miniredis/v2"
"github.com/gin-gonic/gin"
"github.com/redis/go-redis/v9"
+1 -1
View File
@@ -3,7 +3,7 @@ package im
import (
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
func TestFormatQuotedContext(t *testing.T) {
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"fmt"
"testing"
apperrors "github.com/Tencent/WeKnora/internal/errors"
apperrors "academy/internal/errors"
"gorm.io/gorm"
)
+2 -2
View File
@@ -5,8 +5,8 @@ import (
"strings"
"testing"
"github.com/Tencent/WeKnora/internal/event"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/event"
"academy/internal/types"
)
func TestMakeUserKey_UserMode(t *testing.T) {
+2 -2
View File
@@ -15,8 +15,8 @@ import (
"github.com/slack-go/slack"
"github.com/slack-go/slack/slackevents"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
)
// Compile-time checks.
+1 -1
View File
@@ -3,7 +3,7 @@ package slack
import (
"testing"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
slacklib "github.com/slack-go/slack"
)
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"strings"
"testing"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
slacklib "github.com/slack-go/slack"
"github.com/stretchr/testify/require"
)
+3 -3
View File
@@ -6,9 +6,9 @@ import (
slackpkg "github.com/slack-go/slack"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
"academy/internal/logger"
secutils "academy/internal/utils"
)
// NewFactory returns an im.AdapterFactory for Slack channels.
+3 -3
View File
@@ -8,9 +8,9 @@ import (
"github.com/slack-go/slack/slackevents"
"github.com/slack-go/slack/socketmode"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
"academy/internal/logger"
secutils "academy/internal/utils"
)
// MessageHandler is called when an IM message is received via long connection.
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"strings"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
)
type deliveryMessageService struct {
+3 -3
View File
@@ -7,9 +7,9 @@ import (
"testing/synctest"
"time"
"github.com/Tencent/WeKnora/internal/event"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"academy/internal/event"
"academy/internal/types"
"academy/internal/types/interfaces"
)
type streamExitSessionService struct {
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"context"
"time"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/logger"
)
// defaultRecycleInterval is how often a supervised long connection is proactively
+3 -3
View File
@@ -15,9 +15,9 @@ import (
"github.com/gin-gonic/gin"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
"academy/internal/logger"
secutils "academy/internal/utils"
)
// Compile-time checks.
+1 -1
View File
@@ -3,7 +3,7 @@ package telegram
import (
"testing"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
func TestParseTelegramMessage_ForumTopicThread(t *testing.T) {
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
)
// NewFactory returns an im.AdapterFactory for Telegram bot channels.
+3 -3
View File
@@ -8,9 +8,9 @@ import (
"net/http"
"time"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
"academy/internal/logger"
secutils "academy/internal/utils"
)
// MessageHandler is called when an IM message is received via long polling.
+2 -2
View File
@@ -8,7 +8,7 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/google/uuid"
"gorm.io/gorm"
)
@@ -238,7 +238,7 @@ func (ch *IMChannel) computeBotIdentity() string {
return ""
}
// ChannelSession maps an IM channel (user+chat combination) to a WeKnora session.
// ChannelSession maps an IM channel (user+chat combination) to a Academy session.
// This allows the IM integration to maintain conversation continuity.
type ChannelSession struct {
ID string `json:"id" gorm:"type:varchar(36);primaryKey;default:uuid_generate_v4()"`
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
+5 -5
View File
@@ -22,9 +22,9 @@ import (
"net/url"
"time"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
"academy/internal/logger"
secutils "academy/internal/utils"
"github.com/gin-gonic/gin"
)
@@ -35,7 +35,7 @@ const (
// defaultBotType is the bot_type for iLink get_bot_qrcode / get_qrcode_status.
defaultBotType = "3"
// channelVersion is sent in base_info with every API request.
channelVersion = "weknora-1.0.0"
channelVersion = "academy-1.0.0"
)
var ilinkHTTPClient = secutils.NewSSRFSafeHTTPClient(secutils.SSRFSafeHTTPClientConfig{
@@ -108,7 +108,7 @@ func (a *Adapter) SendReply(ctx context.Context, incoming *im.IncomingMessage, r
"msg": map[string]interface{}{
"from_user_id": "",
"to_user_id": incoming.UserID,
"client_id": fmt.Sprintf("weknora_%d", time.Now().UnixNano()),
"client_id": fmt.Sprintf("academy_%d", time.Now().UnixNano()),
"message_type": 2, // BOT
"message_state": 2, // FINISH
"item_list": []map[string]interface{}{
+1 -1
View File
@@ -1,4 +1,4 @@
// Package wechat implements the WeChat personal account IM adapter for WeKnora
// Package wechat implements the WeChat personal account IM adapter for Academy
// via the Tencent iLink Bot API (ilinkai.weixin.qq.com).
package wechat
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
)
// NewFactory returns an im.AdapterFactory for WeChat channels (iLink bot).
+3 -3
View File
@@ -20,9 +20,9 @@ import (
"strings"
"time"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
"academy/internal/logger"
secutils "academy/internal/utils"
)
const (
+1 -1
View File
@@ -21,7 +21,7 @@ import (
"net/url"
"time"
secutils "github.com/Tencent/WeKnora/internal/utils"
secutils "academy/internal/utils"
)
// QRCodeResult holds the result of requesting a login QR code.
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"strings"
"testing"
secutils "github.com/Tencent/WeKnora/internal/utils"
secutils "academy/internal/utils"
)
// setWhitelistForTest swaps the SSRF whitelist singleton for the duration of
+2 -2
View File
@@ -4,8 +4,8 @@ import (
"context"
"fmt"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
)
// NewFactory returns an im.AdapterFactory for WeCom channels.
+4 -4
View File
@@ -20,9 +20,9 @@ import (
"sync/atomic"
"time"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
"academy/internal/logger"
secutils "academy/internal/utils"
ws "github.com/gorilla/websocket"
)
@@ -784,7 +784,7 @@ func stripAtMentionBasic(content string) string {
}
// stripAtMention removes the leading "@BotName" prefix from group chat messages.
// Bot names may contain spaces (e.g., "WeKnora Bot"), so this adds two strategies
// Bot names may contain spaces (e.g., "Academy Bot"), so this adds two strategies
// on top of stripAtMentionBasic: (1) double-space split with bot-name learning,
// (2) cached/configured bot name prefix match.
// Concurrent calls are safe; atomic.Value races are benign (same bot name).
+15 -15
View File
@@ -16,10 +16,10 @@ func TestStripAtMentionBasic(t *testing.T) {
{"single-word bot double-space", "@Bot /stop", "/stop"},
{"single-word bot single-space", "@Bot /stop", "/stop"},
{"single-word bot double-space chinese", "@Bot 你好世界", "你好世界"},
{"multi-word bot double-space", "@WeKnora Bot /stop", "/stop"},
{"multi-word bot double-space chinese", "@WeKnora Bot 什么是上下文工程", "什么是上下文工程"},
{"multi-word bot single-space command", "@WeKnora Bot /stop", "/stop"},
{"multi-word bot single-space chinese", "@WeKnora Bot 什么是老登", "什么是老登"},
{"multi-word bot double-space", "@Academy Bot /stop", "/stop"},
{"multi-word bot double-space chinese", "@Academy Bot 什么是上下文工程", "什么是上下文工程"},
{"multi-word bot single-space command", "@Academy Bot /stop", "/stop"},
{"multi-word bot single-space chinese", "@Academy Bot 什么是老登", "什么是老登"},
{"leading whitespace", " @Bot hello ", "hello"},
{"double-space in user content", "@Bot hello world", "hello world"},
}
@@ -37,25 +37,25 @@ func TestLongConnClient_StripAtMention(t *testing.T) {
t.Run("learns bot name from double-space then handles single-space", func(t *testing.T) {
c := &LongConnClient{}
// First message: double-space → learn "WeKnora Bot"
got := c.stripAtMention("@WeKnora Bot 什么是上下文工程")
// First message: double-space → learn "Academy Bot"
got := c.stripAtMention("@Academy Bot 什么是上下文工程")
if got != "什么是上下文工程" {
t.Errorf("first message: got %q, want %q", got, "什么是上下文工程")
}
// Verify bot name was cached
if name, _ := c.botDisplayName.Load().(string); name != "WeKnora Bot" {
t.Errorf("cached bot name = %q, want %q", name, "WeKnora Bot")
if name, _ := c.botDisplayName.Load().(string); name != "Academy Bot" {
t.Errorf("cached bot name = %q, want %q", name, "Academy Bot")
}
// Second message: single-space → should use cached name
got = c.stripAtMention("@WeKnora Bot /stop")
got = c.stripAtMention("@Academy Bot /stop")
if got != "/stop" {
t.Errorf("second message: got %q, want %q", got, "/stop")
}
// Single-space with chinese content
got = c.stripAtMention("@WeKnora Bot 什么是B+树")
got = c.stripAtMention("@Academy Bot 什么是B+树")
if got != "什么是B+树" {
t.Errorf("chinese single-space: got %q, want %q", got, "什么是B+树")
}
@@ -63,10 +63,10 @@ func TestLongConnClient_StripAtMention(t *testing.T) {
t.Run("preconfigured bot name", func(t *testing.T) {
c := &LongConnClient{}
c.botDisplayName.Store("WeKnora Bot")
c.botDisplayName.Store("Academy Bot")
// Single-space should work immediately without learning
got := c.stripAtMention("@WeKnora Bot /stop")
got := c.stripAtMention("@Academy Bot /stop")
if got != "/stop" {
t.Errorf("got %q, want %q", got, "/stop")
}
@@ -131,7 +131,7 @@ func TestLongConnClient_StripAtMention(t *testing.T) {
t.Run("cold start single-space command", func(t *testing.T) {
c := &LongConnClient{}
// No cached name, single space → heuristic detects " /" boundary
got := c.stripAtMention("@WeKnora Bot /stop")
got := c.stripAtMention("@Academy Bot /stop")
if got != "/stop" {
t.Errorf("got %q, want %q", got, "/stop")
}
@@ -140,7 +140,7 @@ func TestLongConnClient_StripAtMention(t *testing.T) {
t.Run("cold start single-space chinese", func(t *testing.T) {
c := &LongConnClient{}
// No cached name, single space → heuristic detects non-ASCII boundary
got := c.stripAtMention("@WeKnora Bot 什么是老登")
got := c.stripAtMention("@Academy Bot 什么是老登")
if got != "什么是老登" {
t.Errorf("got %q, want %q", got, "什么是老登")
}
@@ -149,7 +149,7 @@ func TestLongConnClient_StripAtMention(t *testing.T) {
t.Run("cold start all-ascii content falls back to first word", func(t *testing.T) {
c := &LongConnClient{}
// No cached name, all ASCII → heuristic can't find boundary, strips first @word
got := c.stripAtMention("@WeKnora Bot hello")
got := c.stripAtMention("@Academy Bot hello")
if got != "Bot hello" {
t.Errorf("got %q, want %q", got, "Bot hello")
}
+2 -2
View File
@@ -3,7 +3,7 @@ package wecom
import (
"testing"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
// mixedMsg builds a botMessage with msgtype "mixed" from text/image parts.
@@ -86,7 +86,7 @@ func TestConvertMixedMessage(t *testing.T) {
},
{
name: "group chat: mention stripped from caption",
msg: mixedMsg(textItem("@WeKnora Bot 这张图里是什么?"), imageItem("https://img.example/1", "key1")),
msg: mixedMsg(textItem("@Academy Bot 这张图里是什么?"), imageItem("https://img.example/1", "key1")),
chatType: im.ChatTypeGroup,
wantType: im.MessageTypeImage,
wantContent: "这张图里是什么?",
+1 -1
View File
@@ -3,7 +3,7 @@ package wecom
import (
"strings"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
// extractQuoteContent extracts text content from a quoted botMessage.
+4 -4
View File
@@ -1,4 +1,4 @@
// Package wecom implements the WeCom (企业微信) IM adapter for WeKnora.
// Package wecom implements the WeCom (企业微信) IM adapter for Academy.
//
// WeCom Smart Bot flow:
// 1. User sends a message to the bot (direct or @mention in group)
@@ -31,9 +31,9 @@ import (
"sync"
"time"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
secutils "github.com/Tencent/WeKnora/internal/utils"
"academy/internal/im"
"academy/internal/logger"
secutils "academy/internal/utils"
"github.com/gin-gonic/gin"
)
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"fmt"
"io"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
"github.com/gin-gonic/gin"
)
+3 -3
View File
@@ -13,9 +13,9 @@ import (
"errors"
"fmt"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/im/wecom"
"github.com/Tencent/WeKnora/internal/types"
"academy/internal/im"
"academy/internal/im/wecom"
"academy/internal/types"
"gorm.io/gorm"
)
+3 -3
View File
@@ -21,8 +21,8 @@ import (
"github.com/gin-gonic/gin"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
)
// textMessageType is the Yunzhijia message type value for plain text messages.
@@ -321,7 +321,7 @@ func (a *Adapter) SendReply(ctx context.Context, incoming *im.IncomingMessage, r
payload := sendMessagePayload{
MsgType: textMessageType,
Content: reply.Content,
// WeKnora replies are authored in Markdown by default (see im.ReplyMessage.Content),
// Academy replies are authored in Markdown by default (see im.ReplyMessage.Content),
// so request Markdown rendering from Yunzhijia unless explicitly overridden via
// reply.Extra["yunzhijia_format_type"] (empty string disables the param entirely).
Param: &sendMessageParam{FormatType: markdownFormatType},
+6 -6
View File
@@ -16,7 +16,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
)
type roundTripFunc func(*http.Request) (*http.Response, error)
@@ -28,8 +28,8 @@ func (f roundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) {
func TestVerifyCallbackSignature(t *testing.T) {
gin.SetMode(gin.TestMode)
msg := callbackMessage{
Type: 2, RobotID: "robot", RobotName: "WeKnora", OperatorOpenid: "user",
OperatorName: "User", Time: 123, MsgID: "message", Content: "@WeKnora hello",
Type: 2, RobotID: "robot", RobotName: "Academy", OperatorOpenid: "user",
OperatorName: "User", Time: 123, MsgID: "message", Content: "@Academy hello",
}
body, err := json.Marshal(msg)
if err != nil {
@@ -56,7 +56,7 @@ func TestVerifyCallbackSignature(t *testing.T) {
func TestToIncomingMessageRequiresRobotMention(t *testing.T) {
msg := &callbackMessage{
Type: 2, RobotID: "robot", RobotName: "WeKnora", OperatorOpenid: "user",
Type: 2, RobotID: "robot", RobotName: "Academy", OperatorOpenid: "user",
OperatorName: "User", Time: 123, MsgID: "message", Content: "hello",
}
if got := toIncomingMessage(t.Context(), msg); got != nil {
@@ -65,10 +65,10 @@ func TestToIncomingMessageRequiresRobotMention(t *testing.T) {
}
func TestCleanAtMentionRequiresNameBoundary(t *testing.T) {
if _, mentioned := cleanAtMention("@WeKnoraPlus hello", "WeKnora"); mentioned {
if _, mentioned := cleanAtMention("@AcademyPlus hello", "Academy"); mentioned {
t.Fatal("longer user name must not be treated as a robot mention")
}
if got, mentioned := cleanAtMention("@WeKnora:你好", "WeKnora"); !mentioned || got != "你好" {
if got, mentioned := cleanAtMention("@Academy:你好", "Academy"); !mentioned || got != "你好" {
t.Fatalf("cleanAtMention() = %q, %v; want 你好, true", got, mentioned)
}
}
+2 -2
View File
@@ -5,8 +5,8 @@ import (
"fmt"
"strconv"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
)
// NewFactory returns an im.AdapterFactory for Yunzhijia channels.
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"net/url"
"strings"
"github.com/Tencent/WeKnora/internal/ipclass"
"github.com/Tencent/WeKnora/internal/utils"
"academy/internal/ipclass"
"academy/internal/utils"
)
func deriveWebSocketURL(sendMsgURL, allowedHostSuffix string) (string, error) {
@@ -5,7 +5,7 @@ import (
"errors"
"testing"
"github.com/Tencent/WeKnora/internal/utils"
"academy/internal/utils"
)
func whitelistOnly(t *testing.T, whitelist, only string) {
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"sync/atomic"
"time"
"github.com/Tencent/WeKnora/internal/im"
"github.com/Tencent/WeKnora/internal/logger"
"academy/internal/im"
"academy/internal/logger"
ws "github.com/gorilla/websocket"
)
+3 -3
View File
@@ -11,19 +11,19 @@ import (
"testing"
"time"
"github.com/Tencent/WeKnora/internal/im"
"academy/internal/im"
ws "github.com/gorilla/websocket"
)
const testBusinessMessage = `{
"type": 2,
"robotId": "bot-1",
"robotName": "WeKnora",
"robotName": "Academy",
"operatorOpenid": "user-1",
"operatorName": "User",
"time": 1719648000000,
"msgId": "msg-1",
"content": "@WeKnora hello",
"content": "@Academy hello",
"groupType": 1
}`