Commit Graph

415 Commits

Author SHA1 Message Date
Kgothatso Ngako
07e1db950a Implement DatabaseMantraRepository.addArtifact
addArtifact was a stub: it returned null unconditionally (so the
ViewModel's success path never fired), called a TODO() addArtifactVersion
that threw mid-flow, and passed empty chatRoomId/userPublicKey — yielding
a wrong event id and foreign-key violations.

- Persist the MantraArtifact with the real chatRoomId and userPublicKey,
  plus a MarmotInnerEvent rumor (marmotGroupEventId IS NULL) that the
  outbound pipeline encrypts into the group, mirroring sendChatMessage.
  Set the inner event kind to ArtifactEvent.KIND so it matches the hashed
  id (it previously defaulted to ChatEvent.KIND).
- Implement addArtifactVersion (was TODO) and create the initial version;
  add MantraArtifactVersion.fromArtifactVersionEventTemplate mirroring
  MantraArtifact for consistent id derivation.
- Return the created inner event so the caller can detect success; wrap
  writes in try/catch to fail without crashing.

Thread the required dialectId plus chatRoomId/userPublicKey and the
visibility/license params (defaulting to private/cc) through
MantraRepository and AddArtifactViewModel. The ViewModel now validates
inputs up front, routes exceptions to onFailure, clears fields only on
success, and uses isActionPending to block double submits. The screen
passes dialectId = null with a TODO until a dialect picker exists; the
flow fails gracefully in the meantime.

Also fix the ArtifactVersionEvent.build phantom generic
(TagArrayBuilder<ArtifactEvent> -> <ArtifactVersionEvent>) so it returns
the correct EventTemplate type.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-26 00:17:17 +02:00
Kgothatso Ngako
8e3c1cffe2 Split nip30303 compound metadata tags into per-field tags
The artifact/dialect/chapter/translation-version events packed several
independent attributes into single positional tags
(["artifact", url, visibility, license], ["dialect", name, country,
language], etc.). Positional packing made every field mandatory (a
missing or malformed field nulled the whole metadata blob), blocked
extension, and forced ArtifactMetadataTag and
TranslationArtifactVersionMetadataTag to share TAG_NAME "artifact" with
field 1 meaning url vs name.

Replace the four compound tags with seven shared single-field tags
(NameTag, UrlTag, VisibilityTag, LicenseTag, CountryTag, LanguageTag,
OriginalTextTag), following the NIP-23 one-tag-per-field convention.
Event accessors now read each field independently and build()/toXEvent()
emit one tag per field; from...Event() readers let-chain the per-field
accessors. This also removes the duplicate "artifact" tag-name collision.

Note: breaking wire-format change for kinds 30300/30302/30304/30306;
safe now since these events are not published yet.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-26 00:06:12 +02:00
Kgothatso Ngako
c45a310641 Fix nip30303 tag parsing bugs
WordStatisticsTag.parse used has(3) but the tag has only 3 elements
(indices 0-2), so the guard never passed and parse always returned null
— silently breaking all Chapter and Chunk event parsing. Correct to
has(2).

Also replace unsafe tag[n].toInt() with toIntOrNull() in WordStatisticsTag
and IndexTag so a malformed numeric field from a relay returns null
instead of throwing NumberFormatException up through the parse loop.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-25 23:56:18 +02:00
Kgothatso Ngako
0d79c3ecee Basic logic for adding new artifact 2026-07-24 23:13:47 +02:00
Kgothatso Ngako
9444f8280b Some foundational logic to add artifact 2026-07-22 23:12:36 +02:00
Kgothatso Ngako
499bd54704 Add artifact UI flow 2026-07-20 02:30:15 +02:00
Kgothatso Ngako
3a830d77d6 Add chat room id on mantra tables 2026-07-19 21:08:44 +02:00
Kgothatso Ngako
3640a77413 Add more associations 2026-07-19 20:58:11 +02:00
Kgothatso Ngako
03c3e56b26 Bug fix for translationChapter primary key 2026-07-19 19:49:07 +02:00
Kgothatso Ngako
0bb421aefc Save groupEvent 2026-07-19 19:45:22 +02:00
Kgothatso Ngako
9cf95483e8 Consume inbound mantra events 2026-07-19 19:38:13 +02:00
Kgothatso Ngako
1b19c6a1be Create nostr events from database data 2026-07-19 19:15:42 +02:00
Kgothatso Ngako
ed70df2c11 Consume mantra nostr events 2026-07-19 03:21:38 +02:00
Kgothatso Ngako
9cd06f3b40 Add associations 2026-07-19 02:47:47 +02:00
Kgothatso Ngako
d2b64b5d91 Maintain contributors with role attributor instead of exact role having it's own class 2026-07-17 21:28:39 +02:00
Kgothatso Ngako
803b9b6755 Relay hints and such 2026-07-17 11:05:55 +02:00
Kgothatso Ngako
bdcf685537 Make mantra tags event references 2026-07-17 10:44:02 +02:00
Kgothatso Ngako
3bc12ca344 Add tag builders 2026-07-17 01:02:29 +02:00
Kgothatso Ngako
9b2022e79f Add dao for mantra objects 2026-07-16 00:08:01 +02:00
Kgothatso Ngako
5bd85a5750 Use ListItem on Profile 2026-07-15 23:46:09 +02:00
Kgothatso Ngako
62695d3277 Add signature and use id 2026-07-15 23:42:14 +02:00
Kgothatso Ngako
a84628acbb Add helper functions to create mantra nostr event 2026-07-15 23:34:37 +02:00
Kgothatso Ngako
d2370a512a Add mantra nostr event kinds 2026-07-15 23:08:08 +02:00
Kgothatso Ngako
ab4d24282d Add mantra models 2026-07-15 22:39:01 +02:00
Kgothatso Ngako
6cdddee424 Rename TorchDatabase to MantraDatabase 2026-07-15 01:19:53 +02:00
Kgothatso Ngako
9abdf42921 Refactor torch to mantra 2026-07-15 01:14:46 +02:00
Kgothatso Ngako
e439b48fcd Add TODO key packages 2026-07-15 00:44:00 +02:00
Kgothatso Ngako
4178e5e544 Rotate keys 2026-07-15 00:37:35 +02:00
Kgothatso Ngako
2477f77fb8 Bug fix on chat creation 2026-07-14 23:37:37 +02:00
Kgothatso Ngako
1bf3ec32ac Process group member changes on commit 2026-07-14 00:31:13 +02:00
Kgothatso Ngako
be6c49ead0 Remove debug function 2026-07-13 23:14:57 +02:00
Kgothatso Ngako
125d8ff904 Bug fix on sending welcome event 2026-07-13 22:42:53 +02:00
Kgothatso Ngako
04604c858d Don't find deleted chat by Id 2026-07-13 00:54:24 +02:00
Kgothatso Ngako
33ab19f1c6 Add text 2026-07-13 00:51:28 +02:00
Kgothatso Ngako
d3eed07d7c Don't show deleted chat 2026-07-13 00:44:32 +02:00
Kgothatso Ngako
30db090de8 Leave and delete group logic 2026-07-13 00:35:20 +02:00
Kgothatso Ngako
947ae439f0 Observe profile and sync metadata/keypackage event 2026-07-13 00:12:12 +02:00
Kgothatso Ngako
8e1ab672bb Clean up code 2026-07-12 23:26:49 +02:00
Kgothatso Ngako
c726d84629 Clean up code 2026-07-12 23:26:29 +02:00
Kgothatso Ngako
1fb66300f8 Add dialog to start chat 2026-07-12 23:15:03 +02:00
Kgothatso Ngako
56dc651b1d hide sheet when performing action from bottom sheet 2026-07-12 22:25:04 +02:00
Kgothatso Ngako
8c17e937a1 Add bottom sheet to home screen 2026-07-12 22:15:11 +02:00
Kgothatso Ngako
37085efc65 Show description on chat room detail 2026-07-12 21:53:02 +02:00
Kgothatso Ngako
f53b407e58 Add description to chat room 2026-07-12 21:49:59 +02:00
Kgothatso Ngako
7e1be3c3f6 Use unique constraint when saving to the database. 2026-07-12 21:15:27 +02:00
Kgothatso Ngako
9331669aea Save marmotGroupEvent 2026-07-12 20:54:08 +02:00
Kgothatso Ngako
31257a8c09 Update tags 2026-07-12 18:51:15 +02:00
Kgothatso Ngako
4fbdb561b8 Add ChatRoomDetailScreen 2026-07-12 18:07:59 +02:00
Kgothatso Ngako
ec48eea6d9 Rename file 2026-07-12 17:30:07 +02:00
Kgothatso Ngako
1d59cf00a8 More renaming for chatRoom vs chatMessage list 2026-07-12 17:29:31 +02:00