mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-12-02 16:58:23 +01: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:
@@ -56,9 +56,6 @@ Map< String, List<List<String>> > gReactions = {};
|
|||||||
// is updated as kind 3 events are received
|
// is updated as kind 3 events are received
|
||||||
Map< String, List<Contact>> gContactLists = {};
|
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
|
// bots ignored to reduce spam
|
||||||
List<String> gBots = [ "3b57518d02e6acfd5eb7198530b2e351e5a52278fb2499d14b66db2b5791c512", // robosats orderbook
|
List<String> gBots = [ "3b57518d02e6acfd5eb7198530b2e351e5a52278fb2499d14b66db2b5791c512", // robosats orderbook
|
||||||
"887645fef0ce0c3c1218d2f5d8e6132a19304cdc57cd20281d082f38cfea0072", // bestofhn
|
"887645fef0ce0c3c1218d2f5d8e6132a19304cdc57cd20281d082f38cfea0072", // bestofhn
|
||||||
@@ -324,12 +321,7 @@ class EventData {
|
|||||||
if( kind != 42) {
|
if( kind != 42) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
for(int i = 0; i < tags.length; i++) {
|
return getParent();
|
||||||
if( tags[i][0] == "#e") {
|
|
||||||
return tags[i][1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// prints event data in the format that allows it to be shown in tree form by the Tree class
|
// 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;
|
return pubkeys;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class Tree {
|
|||||||
} else {
|
} else {
|
||||||
List<String> temp = [];
|
List<String> temp = [];
|
||||||
temp.add(eId);
|
temp.add(eId);
|
||||||
|
//String name = json['name'];
|
||||||
ChatRoom room = ChatRoom(chatRoomId, "", "", "", temp);
|
ChatRoom room = ChatRoom(chatRoomId, "", "", "", temp);
|
||||||
rooms[chatRoomId] = room;
|
rooms[chatRoomId] = room;
|
||||||
if( gDebug > 0) print("Added new chat room object $chatRoomId and added message to it. ");
|
if( gDebug > 0) print("Added new chat room object $chatRoomId and added message to it. ");
|
||||||
@@ -68,18 +69,19 @@ class Tree {
|
|||||||
|
|
||||||
if(eKind == 40) {
|
if(eKind == 40) {
|
||||||
String chatRoomId = eId;
|
String chatRoomId = eId;
|
||||||
|
dynamic json = jsonDecode(value.e.eventData.content);
|
||||||
|
|
||||||
if( rooms.containsKey(chatRoomId)) {
|
if( rooms.containsKey(chatRoomId)) {
|
||||||
if( rooms[chatRoomId]?.name == "") {
|
if( rooms[chatRoomId]?.name == "") {
|
||||||
dynamic json = jsonDecode(value.e.eventData.content);
|
|
||||||
if( gDebug > 0) print('Added room name = ${json['name']} for $chatRoomId' );
|
if( gDebug > 0) print('Added room name = ${json['name']} for $chatRoomId' );
|
||||||
rooms[chatRoomId]?.name = json['name'];
|
rooms[chatRoomId]?.name = json['name'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<String> temp = [];
|
List<String> temp = [];
|
||||||
temp.add(eId);
|
//temp.add(eId);
|
||||||
ChatRoom room = ChatRoom(chatRoomId, "", "", "", temp);
|
ChatRoom room = ChatRoom(chatRoomId, json['name'], json['about'], "", []);
|
||||||
rooms[chatRoomId] = room;
|
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("-----------$name---------");
|
||||||
print("Total number of messages: $numMessages");
|
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");
|
print("\n\n");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -459,6 +474,12 @@ class Tree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strTags += '["client","$clientName"]' ;
|
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) {
|
if( latestEventId.isNotEmpty) {
|
||||||
String? pTagPubkey = allChildEventsMap[latestEventId]?.e.eventData.pubkey;
|
String? pTagPubkey = allChildEventsMap[latestEventId]?.e.eventData.pubkey;
|
||||||
if( pTagPubkey != null) {
|
if( pTagPubkey != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user