added some unused code for isRelevant logic in writing to file

This commit is contained in:
Vishal 2022-12-28 21:18:49 +05:30
parent 97ed8ac742
commit 2edf5bb361
2 changed files with 34 additions and 0 deletions

View File

@ -2046,6 +2046,16 @@ class Store {
return room;
}
// TODO to be finished
bool isRelevant(Tree tree) {
//Set<String> contacts = getContactList(userPublicKey);
//contacts = contacts.union(gDefaultFollows);
return true;
}
// Write the tree's events to file as one event's json per line
Future<void> writeEventsToFile(String filename) async {
if( gDebug > 0) print("opening $filename to write to.");
@ -2083,6 +2093,11 @@ class Store {
continue;
}
if( !isRelevant(tree)) {
continue;
}
String temp = tree.event.originalJson.trim();
String line = "${temp}\n";
nLinesStr += line;

View File

@ -92,4 +92,23 @@ Set<String> getOnlyUserEvents(Set<Event> initialEvents, String userPubkey) {
}
});
return userEvents;
}
Set<String> getContactList(String pubkey) {
Set<String> contacts = {};
if( pubkey != "") {
// get the latest kind 3 event for the user, which has the 'follows' list
Event? contactEvent = getContactEvent(userPublicKey);
// if contact list was found, get user's feed; also get some default contacts
if (contactEvent != null ) {
contactEvent.eventData.contactList.forEach((contact) {
contacts.add(contact.contactPubkey);
});
} else {
}
}
return contacts;
}