This commit is contained in:
onysd 2026-07-20 23:43:56 +03:00
parent ebb0be38d9
commit 865b5ff4f4
10 changed files with 43 additions and 29 deletions

View file

@ -114,7 +114,7 @@ func TestServiceRebrandsEveryLanguagePackProjection(t *testing.T) {
t.Fatalf("%s projection: %v", name, err)
}
appName := findLangPackString(pack.Strings, "AppName")
if appName == nil || appName.Value != "Telesrv" || appName.ZeroValue != "No Telesrv accounts" || appName.OneValue != "One Telesrv account" || appName.TwoValue != "Two Telesrv accounts" || appName.FewValue != "Few Telesrv accounts" || appName.ManyValue != "Many Telesrv accounts" || appName.OtherValue != "Other Telesrv accounts" {
if appName == nil || appName.Value != "OwpenGram" || appName.ZeroValue != "No OwpenGram accounts" || appName.OneValue != "One OwpenGram account" || appName.TwoValue != "Two OwpenGram accounts" || appName.FewValue != "Few OwpenGram accounts" || appName.ManyValue != "Many OwpenGram accounts" || appName.OtherValue != "Other OwpenGram accounts" {
t.Fatalf("%s AppName = %+v, want all value forms rebranded", name, appName)
}
if got := stringValue(pack.Strings, "TranslationLink"); got != "https://chat.example/root/en" {
@ -129,7 +129,7 @@ func TestServiceRebrandsEveryLanguagePackProjection(t *testing.T) {
if err != nil {
t.Fatalf("list languages: %v", err)
}
if len(languages) != 1 || languages[0].Name != "Telesrv English" || languages[0].NativeName != "Telesrv English" || languages[0].TranslationsURL != "https://chat.example/root/en" {
if len(languages) != 1 || languages[0].Name != "OwpenGram English" || languages[0].NativeName != "OwpenGram English" || languages[0].TranslationsURL != "https://chat.example/root/en" {
t.Fatalf("languages = %+v, want branded metadata", languages)
}
}

View file

@ -84,7 +84,7 @@ func TestCreateCatalogRevisionPreservesHistoricalRevision(t *testing.T) {
t.Fatalf("current=%+v found=%v", current, found)
}
historical, found, _ := svc.GiftRevisionByID(ctx, first.Gift.RevisionID)
if !found || historical.Stars != 50 || historical.Title != "Telesrv Pin" {
if !found || historical.Stars != 50 || historical.Title != "OwpenGram Pin" {
t.Fatalf("historical=%+v found=%v", historical, found)
}
if _, err := svc.SetCatalogEnabled(ctx, first.Gift.ID+999, false); !errors.Is(err, domain.ErrStarGiftNotFound) {

View file

@ -12,17 +12,17 @@ import (
)
const (
ProductName = "Telesrv"
ProductUsername = "telesrv"
DesktopAppName = "Telesrv Desktop"
AndroidAppName = "Telesrv Android"
IOSAppName = "Telesrv iOS"
MacOSAppName = "Telesrv macOS"
WebAAppName = "Telesrv Web A"
WebKAppName = "Telesrv Web K"
PremiumName = "Telesrv Premium"
StarsName = "Telesrv Stars"
DefaultPublicURL = "https://telesrv.net"
ProductName = "OwpenGram"
ProductUsername = "owpengram"
DesktopAppName = "OwpenGram Desktop"
AndroidAppName = "OwpenGram Android"
IOSAppName = "OwpenGram iOS"
MacOSAppName = "OwpenGram macOS"
WebAAppName = "OwpenGram Web A"
WebKAppName = "OwpenGram Web K"
PremiumName = "OwpenGram Premium"
StarsName = "OwpenGram Stars"
DefaultPublicURL = "https://owpengram.org"
)
// ClientAppName returns the branded display name for a stored client platform.

View file

@ -7,7 +7,7 @@ func TestUserVisibleTextRebrandsWordsAndOfficialHosts(t *testing.T) {
"Telegram telegram TELEGRAM Telegram-like https://translations.telegram.org/en t.me/example desktop.telegram.org",
"https://chat.example/root/",
)
want := "Telesrv Telesrv Telesrv Telesrv-like https://chat.example/root/en chat.example/example chat.example"
want := "OwpenGram OwpenGram OwpenGram OwpenGram-like https://chat.example/root/en chat.example/example chat.example"
if got != want {
t.Fatalf("UserVisibleText() = %q, want %q", got, want)
}
@ -27,9 +27,9 @@ func TestUserVisibleTextPreservesTechnicalIdentifiers(t *testing.T) {
func TestUserVisibleTextRebrandsBareOfficialHostsWithoutTouchingDottedIdentifiers(t *testing.T) {
for input, want := range map[string]string{
"telegram.org": "telesrv.net",
"desktop.telegram.org": "telesrv.net",
"t.me/example": "telesrv.net/example",
"telegram.org": "owpengram.org",
"desktop.telegram.org": "owpengram.org",
"t.me/example": "owpengram.org/example",
"org.telegram.messenger": "org.telegram.messenger",
} {
if got := UserVisibleText(input, ""); got != want {
@ -40,7 +40,7 @@ func TestUserVisibleTextRebrandsBareOfficialHostsWithoutTouchingDottedIdentifier
func TestUserVisibleTextRebrandsLocalizedProductNames(t *testing.T) {
got := UserVisibleText("Телеграмом تيليجرام تلگرام 텔레그램 טלגרם", "")
if want := "Telesrv Telesrv Telesrv Telesrv Telesrv"; got != want {
if want := "OwpenGram OwpenGram OwpenGram OwpenGram OwpenGram"; got != want {
t.Fatalf("UserVisibleText() = %q, want %q", got, want)
}
}

View file

@ -318,7 +318,7 @@ func StickerSet(req *tg.MessagesGetStickerSetRequest) tg.MessagesStickerSetClass
if req != nil && req.Hash == emptyStickerSetHash {
return &tg.MessagesStickerSetNotModified{}
}
title, shortName := "Telesrv Empty Sticker Set", "telesrv_empty"
title, shortName := "OwpenGram Empty Sticker Set", "owpengram_empty"
if req != nil {
switch set := req.Stickerset.(type) {
case *tg.InputStickerSetAnimatedEmoji:

View file

@ -5,16 +5,16 @@ import (
"testing"
)
func TestServiceIdentityAndLoginMessageUseTelesrvBrand(t *testing.T) {
func TestServiceIdentityAndLoginMessageUseOwpenGramBrand(t *testing.T) {
serviceUser := OfficialSystemUser()
if serviceUser.FirstName != "Telesrv" || serviceUser.Username != "telesrv" {
t.Fatalf("service user = %+v, want Telesrv identity", serviceUser)
if serviceUser.FirstName != "OwpenGram" || serviceUser.Username != "owpengram" {
t.Fatalf("service user = %+v, want OwpenGram identity", serviceUser)
}
message, err := OfficialLoginCodeMessage(42, "12345", 1)
if err != nil {
t.Fatalf("build login message: %v", err)
}
if !strings.Contains(message.Body, "Telesrv") || strings.Contains(strings.ToLower(message.Body), "telegram") {
if !strings.Contains(message.Body, "OwpenGram") || strings.Contains(strings.ToLower(message.Body), "telegram") {
t.Fatalf("login message exposes wrong brand: %q", message.Body)
}
}

View file

@ -1,5 +1,7 @@
package domain
import "telesrv/internal/branding"
const (
// OfficialSystemUserID 是 Telegram 兼容客户端识别的官方系统账号。
OfficialSystemUserID int64 = 777000
@ -47,8 +49,8 @@ func OfficialSystemUser() User {
ID: OfficialSystemUserID,
AccessHash: 6599886787491911851,
Phone: "42777",
FirstName: "OwpenGram",
Username: "owpengram",
FirstName: branding.ProductName,
Username: branding.ProductUsername,
Verified: true,
Support: true,
}

View file

@ -33,11 +33,11 @@ func TestCatalogVerifiesSelectedDocument(t *testing.T) {
}
catalog := New(root)
items, err := catalog.List(context.Background())
if err != nil || len(items) != 1 || items[0].ID != 1 || items[0].Title != "Telesrv Pin" {
if err != nil || len(items) != 1 || items[0].ID != 1 || items[0].Title != "OwpenGram Pin" {
t.Fatalf("items=%+v err=%v", items, err)
}
bundle, err := catalog.Bundle(context.Background(), 1, false)
if err != nil || string(bundle.BaseDocument.Data) != string(data) || bundle.Gift.Title != "Telesrv Pin" {
if err != nil || string(bundle.BaseDocument.Data) != string(data) || bundle.Gift.Title != "OwpenGram Pin" {
t.Fatalf("bundle=%+v err=%v", bundle, err)
}
if err := os.WriteFile(filepath.Join(root, "documents", "10.tgs"), []byte("tampered---"), 0o644); err != nil {

View file

@ -215,7 +215,7 @@ func TestSignInServiceNotificationMatchesEnterpriseShape(t *testing.T) {
if update.Popup || update.InboxDate == 0 || update.Media == nil {
t.Fatalf("notification flags/media = popup %v inbox %d media %T", update.Popup, update.InboxDate, update.Media)
}
for _, want := range []string{"New login.", "Test User", "Telesrv Desktop", "Settings > Devices"} {
for _, want := range []string{"New login.", "Test User", "OwpenGram Desktop", "Settings > Devices"} {
if !strings.Contains(update.Message, want) {
t.Fatalf("notification message %q missing %q", update.Message, want)
}

View file

@ -1035,6 +1035,10 @@ func safePublicImageType(value string) bool {
}
}
func legacyTgURL(kind, key, value string) string {
return schemeURL("tg", kind, key, value)
}
func schemeURLValues(scheme, kind string, values url.Values) string {
return (&url.URL{Scheme: scheme, Host: kind, RawQuery: values.Encode()}).String()
}
@ -1182,6 +1186,8 @@ type pageData struct {
CanonicalURL string
DownloadURL string
AppURL template.URL
LegacyTgURL template.URL
AppURLJS template.JS
}
type usernamePageData struct {
@ -1576,8 +1582,14 @@ var landingTemplate = template.Must(template.New("landing").Parse(`<!doctype htm
{{if .Subtitle}}<div class="sub">{{.Subtitle}}</div>{{end}}
{{if .Description}}<div class="about">{{.Description}}</div>{{end}}
<div class="actions"><a class="btn btn-primary" href="{{.AppURL}}">Open in {{.AppName}}</a></div>
{{if .LegacyTgURL}}<div class="sub">Old test clients only: <a href="{{.LegacyTgURL}}" style="color:inherit;text-decoration:underline">open with tg://</a></div>{{end}}
</div>
</main>` + publicBgIconsScript + `
{{if .AppURLJS}}<script>
window.setTimeout(function () {
window.location.href = {{.AppURLJS}};
}, 250);
</script>{{end}}
</body>
</html>
`))