mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-06-26 08:41:14 +02:00
printed messages in rooms. avoided #e for parent of chat message and used e tag like nip 10. fixed so that unknown event can be replied to
This commit is contained in:
parent
dff3ff70b0
commit
5a6ec58a6a
@ -56,9 +56,6 @@ Map< String, List<List<String>> > gReactions = {};
|
||||
// is updated as kind 3 events are received
|
||||
Map< String, List<Contact>> gContactLists = {};
|
||||
|
||||
// chat rooms , mappint from chat room kind 40 event to its information as list where even = key, odd = value
|
||||
Map<String, List<String>> gChatRooms = {};
|
||||
|
||||
// bots ignored to reduce spam
|
||||
List<String> gBots = [ "3b57518d02e6acfd5eb7198530b2e351e5a52278fb2499d14b66db2b5791c512", // robosats orderbook
|
||||
"887645fef0ce0c3c1218d2f5d8e6132a19304cdc57cd20281d082f38cfea0072", // bestofhn
|
||||
@ -324,12 +321,7 @@ class EventData {
|
||||
if( kind != 42) {
|
||||
return "";
|
||||
}
|
||||
for(int i = 0; i < tags.length; i++) {
|
||||
if( tags[i][0] == "#e") {
|
||||
return tags[i][1];
|
||||
}
|
||||
}
|
||||
return "";
|
||||
return getParent();
|
||||
}
|
||||
|
||||
// prints event data in the format that allows it to be shown in tree form by the Tree class
|
||||
@ -577,5 +569,7 @@ Set<String> getPublicKeyFromName(String userName) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
return pubkeys;
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ class Tree {
|
||||
} else {
|
||||
List<String> temp = [];
|
||||
temp.add(eId);
|
||||
//String name = json['name'];
|
||||
ChatRoom room = ChatRoom(chatRoomId, "", "", "", temp);
|
||||
rooms[chatRoomId] = room;
|
||||
if( gDebug > 0) print("Added new chat room object $chatRoomId and added message to it. ");
|
||||
@ -68,18 +69,19 @@ class Tree {
|
||||
|
||||
if(eKind == 40) {
|
||||
String chatRoomId = eId;
|
||||
dynamic json = jsonDecode(value.e.eventData.content);
|
||||
|
||||
if( rooms.containsKey(chatRoomId)) {
|
||||
if( rooms[chatRoomId]?.name == "") {
|
||||
dynamic json = jsonDecode(value.e.eventData.content);
|
||||
if( gDebug > 0) print('Added room name = ${json['name']} for $chatRoomId' );
|
||||
rooms[chatRoomId]?.name = json['name'];
|
||||
}
|
||||
} else {
|
||||
List<String> temp = [];
|
||||
temp.add(eId);
|
||||
ChatRoom room = ChatRoom(chatRoomId, "", "", "", temp);
|
||||
//temp.add(eId);
|
||||
ChatRoom room = ChatRoom(chatRoomId, json['name'], json['about'], "", []);
|
||||
rooms[chatRoomId] = room;
|
||||
if( gDebug > 0) print("Added new chat room $chatRoomId.");
|
||||
if( gDebug > 0) print("Added new chat room $chatRoomId with name ${json['name']} .");
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,6 +383,19 @@ class Tree {
|
||||
|
||||
print("-----------$name---------");
|
||||
print("Total number of messages: $numMessages");
|
||||
|
||||
List<String> messageIds = value.messageIds;
|
||||
for( int i = 0; i < messageIds.length; i++) {
|
||||
if( allChildEventsMap.containsKey(messageIds[i])) {
|
||||
Event? e = allChildEventsMap[messageIds[i]]?.e;
|
||||
if( e!= null) {
|
||||
e.printEvent(0);
|
||||
print("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print("\n\n");
|
||||
});
|
||||
}
|
||||
@ -459,6 +474,12 @@ class Tree {
|
||||
}
|
||||
|
||||
strTags += '["client","$clientName"]' ;
|
||||
|
||||
// in case we are given valid length id, but we can't find the event in our internal db, then we just send the reply to given id
|
||||
if( latestEventId.isEmpty && replyToId.length == 64) {
|
||||
latestEventId = replyToId;
|
||||
}
|
||||
|
||||
if( latestEventId.isNotEmpty) {
|
||||
String? pTagPubkey = allChildEventsMap[latestEventId]?.e.eventData.pubkey;
|
||||
if( pTagPubkey != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user