Mark Telegram messages in Lumi
This commit is contained in:
1 parent
4ea83c536a
commit
bd610f9d93
18 files changed
+81
-4
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- Mark Telegram-relayed Lumi messages with their source.
|
||||
- Collapse each break kind in settings and expand it on click.
|
||||
- Keep Linux break reminder text and progress bars in separate rows.
|
||||
- Catalog games can award their own achievements, with the usual top-right notification.
|
||||
|
||||
@@ -843,7 +843,14 @@ LumiView :: (message: LumiMessage, commands: LumiCommands, revision: s64) -> Lum
|
||||
.text = ifx row.developer then LumiViewLocaleHost("lumi_developer") else "Lumi",
|
||||
.font = Scale(12)})
|
||||
}
|
||||
text_top := Scale(ifx row.user then 12 else 32)
|
||||
from_telegram := row.user && row.kind == LUMI_CHAT_TEXT && row.payload == "telegram"
|
||||
if from_telegram {
|
||||
Text(frame.session, TextProps.{.key = cast(u64)(300408 + index * 4),
|
||||
.bounds = Bounds(left + Scale(14), top + Scale(8),
|
||||
bubble_width - Scale(28), Scale(16)),
|
||||
.text = LumiViewLocaleHost("lumi_from_telegram"), .font = Scale(11)})
|
||||
}
|
||||
text_top := Scale(ifx row.user then (ifx from_telegram then 30 else 12) else 32)
|
||||
if row.developer && row.quote.count > 0 {
|
||||
FeedbackQuote(row, index, left, top + text_top, bubble_width)
|
||||
text_top += Scale(LUMI_QUOTE_HEIGHT)
|
||||
|
||||
@@ -2925,6 +2925,9 @@ Odpověď vývojáře:
|
||||
[lumi_developer]
|
||||
Vývojář
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
Z Telegramu
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
Vaše zpětná vazba
|
||||
---
|
||||
|
||||
@@ -2919,6 +2919,9 @@ Antwort vom Entwickler:
|
||||
[lumi_developer]
|
||||
Entwickler
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
Von Telegram
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
Dein Feedback
|
||||
---
|
||||
|
||||
@@ -2943,6 +2943,9 @@ Developer reply:
|
||||
[lumi_developer]
|
||||
Developer
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
From Telegram
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
Your feedback
|
||||
---
|
||||
|
||||
@@ -2919,6 +2919,9 @@ Respuesta del desarrollador:
|
||||
[lumi_developer]
|
||||
Desarrollador
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
De Telegram
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
Tus comentarios
|
||||
---
|
||||
|
||||
@@ -2907,6 +2907,9 @@ Réponse du développeur :
|
||||
[lumi_developer]
|
||||
Développeur
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
De Telegram
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
Votre retour
|
||||
---
|
||||
|
||||
@@ -2908,6 +2908,9 @@ Balasan pengembang:
|
||||
[lumi_developer]
|
||||
Pengembang
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
Dari Telegram
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
Masukanmu
|
||||
---
|
||||
|
||||
@@ -2908,6 +2908,9 @@ Risposta dello sviluppatore:
|
||||
[lumi_developer]
|
||||
Sviluppatore
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
Da Telegram
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
Il tuo feedback
|
||||
---
|
||||
|
||||
@@ -2904,6 +2904,9 @@ https:// のアドレス(http はこの端末内のみ)とモデル名を入
|
||||
[lumi_developer]
|
||||
開発者
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
Telegramから
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
あなたのフィードバック
|
||||
---
|
||||
|
||||
@@ -2914,6 +2914,9 @@ https:// 주소(http는 이 기기에서만)와 모델 이름을 입력하세요
|
||||
[lumi_developer]
|
||||
개발자
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
Telegram에서
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
내 피드백
|
||||
---
|
||||
|
||||
@@ -2917,6 +2917,9 @@ Resposta do desenvolvedor:
|
||||
[lumi_developer]
|
||||
Desenvolvedor
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
Do Telegram
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
O teu comentário
|
||||
---
|
||||
|
||||
@@ -2913,6 +2913,9 @@ Lumi остаётся без сети, пока вы не примете её у
|
||||
[lumi_developer]
|
||||
Разработчик
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
Из Telegram
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
Ваш отзыв
|
||||
---
|
||||
|
||||
@@ -2919,6 +2919,9 @@ API 密钥
|
||||
[lumi_developer]
|
||||
开发者
|
||||
---
|
||||
[lumi_from_telegram]
|
||||
来自 Telegram
|
||||
---
|
||||
[lumi_your_feedback]
|
||||
你的反馈
|
||||
---
|
||||
|
||||
+12
-2
@@ -255,6 +255,14 @@ LumiStoreLoad :: () {
|
||||
payload = TextFromBytes(payload_bytes[:payload_length])
|
||||
rich_valid = ifx kind == LUMI_CHAT_PROGRESS then LumiChartRead(payload).valid else payload.count == 32
|
||||
}
|
||||
} else if kind == LUMI_CHAT_TEXT && user.value == 1.0 {
|
||||
source_bytes: [16]u8
|
||||
payload_length := ReadStringText(document, FieldAt(document, element, "payload"), source_bytes[:])
|
||||
if payload_length > 0 {
|
||||
source := TextFromBytes(source_bytes[:payload_length])
|
||||
rich_valid = source == "telegram"
|
||||
if rich_valid { payload = "telegram" }
|
||||
}
|
||||
}
|
||||
rich_valid = rich_valid && (kind == LUMI_CHAT_TEXT || user.value == 0.0)
|
||||
}
|
||||
@@ -355,7 +363,8 @@ LumiStoreSave :: () -> bool {
|
||||
}
|
||||
|
||||
LumiStoreAppend :: (text: string, user: bool) {
|
||||
unused LumiStoreAppendCard(text, user, LUMI_CHAT_TEXT, "")
|
||||
source := LumiTelegramMessageSource(lumi_next_message_id)
|
||||
unused LumiStoreAppendCard(text, user, LUMI_CHAT_TEXT, source)
|
||||
}
|
||||
|
||||
LumiStoreAppendCard :: (text: string, user: bool, kind: s32, payload: string) -> bool {
|
||||
@@ -371,11 +380,12 @@ LumiStoreAppendRow :: (message: LumiChatRow) -> bool {
|
||||
if text.count == 0 || text.count >= LUMI_INPUT_MAX {
|
||||
return false
|
||||
}
|
||||
telegram_source := user && kind == LUMI_CHAT_TEXT && payload == "telegram"
|
||||
if kind < LUMI_CHAT_TEXT || kind > LUMI_CHAT_FEEDBACK || kind == LUMI_CHAT_RETIRED ||
|
||||
(kind != LUMI_CHAT_TEXT && user) ||
|
||||
(kind == LUMI_CHAT_PROGRESS && !LumiChartRead(payload).valid) ||
|
||||
(kind == LUMI_CHAT_FEEDBACK && payload.count != 32) ||
|
||||
(kind != LUMI_CHAT_PROGRESS && kind != LUMI_CHAT_FEEDBACK && payload.count != 0) {
|
||||
(!telegram_source && kind != LUMI_CHAT_PROGRESS && kind != LUMI_CHAT_FEEDBACK && payload.count != 0) {
|
||||
return false
|
||||
}
|
||||
if (message.developer && (user || kind != LUMI_CHAT_TEXT)) ||
|
||||
|
||||
@@ -39,6 +39,14 @@ LUMI_CHAT_MAX :: 64
|
||||
// as many older ones each time the chat is scrolled to the top.
|
||||
LUMI_HISTORY_PAGE :: 20
|
||||
|
||||
LumiTelegramMessageSource :: (message_id: string) -> string {
|
||||
prefix := "telegram-"
|
||||
if message_id.count > prefix.count && message_id[:prefix.count] == prefix {
|
||||
return "telegram"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
LumiMessage :: struct {
|
||||
abi: s32
|
||||
action: s32
|
||||
|
||||
@@ -916,6 +916,9 @@ LumiChatRowAt :: (index: s32, access: LumiRowAccess) -> LumiChatRow {
|
||||
LumiRowKey :: (index: s32, access: LumiRowAccess) -> u64 {
|
||||
row := LumiChatRowAt(index, access)
|
||||
marker := cast(u64)(row.kind * 2 + (ifx row.user then 1 else 0) + 1)
|
||||
if row.user && row.kind == LUMI_CHAT_TEXT && row.payload == "telegram" {
|
||||
marker += cast(u64)2
|
||||
}
|
||||
if row.developer {
|
||||
marker ^= KeyHash(row.quote) * cast(u64)31 + cast(u64)1
|
||||
}
|
||||
@@ -935,6 +938,9 @@ LumiMeasuredRow :: (index: s32, access: LumiRowAccess) -> LumiChatRow {
|
||||
cast(float32)(column_width - cast(s32)((ifx row.user then 88.0 else 108.0) * lumi_ui.scale)), 0.0}},
|
||||
DefaultTextFace())
|
||||
height := cast(s32)prepared.bounds.height + cast(s32)((ifx row.user then 38.0 else 58.0) * lumi_ui.scale)
|
||||
if row.user && row.kind == LUMI_CHAT_TEXT && row.payload == "telegram" {
|
||||
height += AppScale(18)
|
||||
}
|
||||
if row.kind == LUMI_CHAT_PROGRESS {
|
||||
height += AppScale(242)
|
||||
} else if row.kind == LUMI_CHAT_FEEDBACK {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#import, file "../src/app/text_buffers.zi";
|
||||
#import, file "../src/app/app_types.zi";
|
||||
#import, file "../src/apps/inbe_types.zi";
|
||||
#import, file "../src/apps/lumi_types.zi";
|
||||
#import, file "../src/apps/lumi_online.zi";
|
||||
#import, file "../src/apps/lumi_connection.zi";
|
||||
#import, file "../src/storage/storage_settings.zi";
|
||||
@@ -77,6 +78,9 @@ InputTestTransport :: () -> AsyncTransport {
|
||||
Check :: () -> s32 {
|
||||
transport := InputTestTransport()
|
||||
check_true("fixture transport available", transport.start != null)
|
||||
check_true("telegram update ids choose the Telegram source",
|
||||
LumiTelegramMessageSource("telegram-17") == "telegram")
|
||||
check_true("local message ids stay local", LumiTelegramMessageSource("local-17") == "")
|
||||
guard := support_begin("/tmp/inbe-lumi-telegram-input-test/")
|
||||
if guard != 0 {
|
||||
return guard
|
||||
@@ -113,7 +117,11 @@ Check :: () -> s32 {
|
||||
check_int("app history never posts to Telegram", mirrors, 0)
|
||||
check_true("input polling retained", polls > 0)
|
||||
check_true("input acknowledged", acks > 0)
|
||||
check_true("incoming message archived", contains(storage_get_setting_text("cell.lumi.message.telegram-17"), "/habits"))
|
||||
incoming_record := storage_get_setting_text("cell.lumi.message.telegram-17")
|
||||
check_true("incoming message archived", contains(incoming_record, "/habits"))
|
||||
check_true("incoming message records Telegram as its source", contains(incoming_record, "\"payload\":\"telegram\""))
|
||||
check_true("incoming message exposes Telegram in the chat row", LumiStoreRow(142).payload == "telegram")
|
||||
check_true("local app message stays unlabelled", LumiStoreRow(140).payload == "")
|
||||
check_true("incoming execution claim retained", storage_get_setting_int("telegram.update.17", 0) == 1)
|
||||
check_true("input schedules regular account sync", app.ui.sync_requested)
|
||||
check_int("input and its response appended once", LumiStoreCount(), expected)
|
||||
@@ -129,6 +137,7 @@ Check :: () -> s32 {
|
||||
check_true("oldest history stays visible", LumiStoreRow(0).text == "1")
|
||||
check_true("app conversation stays visible", LumiStoreRow(140).text == "App message" && LumiStoreRow(141).text == "App response")
|
||||
check_true("incoming history stays visible", LumiStoreRow(142).text == "/habits" && LumiStoreRow(143).text == "No habits yet.")
|
||||
check_true("Telegram source survives reopening", LumiStoreRow(142).payload == "telegram")
|
||||
check_int("complete account outbox survives reopening", read_db_count("SELECT COUNT(*) FROM sync_outbox WHERE entity_type='cell_record' AND entity_id LIKE 'cell.lumi.message.%'"), expected)
|
||||
SecureWipe(*owner.private_key_hex[0], ACCOUNT_PRIVATE_KEY_HEX_SIZE)
|
||||
storage_close()
|
||||
|
||||
Reference in new issue
Block a user