diff --git a/blasta.py b/blasta.py index 1201ffa..885ed26 100644 --- a/blasta.py +++ b/blasta.py @@ -1444,17 +1444,17 @@ class HttpInstance: override: str = Form(None)): jabber_id = Utilities.is_jid_matches_to_session(accounts, sessions, request) if jabber_id: + xmpp_instance = accounts[jabber_id] if file: # TODO If node does not exist, redirect to result page with # a message that bookmarks are empty. # NOTE No. - # TODO match/case public, private, read - node_id = node[node]['name'] - node_title = node[node]['title'] - node_subtitle = node[node]['subtitle'] - node_access_model = node[node]['access_model'] + node_id = nodes[node]['name'] + node_title = nodes[node]['title'] + node_subtitle = nodes[node]['subtitle'] + node_access_model = nodes[node]['access_model'] if not await XmppPubsub.is_node_exist(xmpp_instance, node_id): iq = XmppPubsub.create_node_atom( xmpp_instance, jabber_id, node_id, node_title, @@ -1463,33 +1463,45 @@ class HttpInstance: #return {"filename": file.filename} content = file.file.read().decode() + + # TODO Add match/case for filetype. + entries = tomllib.loads(content) # entries_node = entries[node] + #breakpoint() + #for entry in entries: print(entry) + name = jabber_id.split('@')[0] # timestamp = datetime.now().isoformat() db_file = 'main.sqlite' - for entry in entries: - url_hash = item_id = Utilities.hash_url_to_md5(entry['link']) - instances = SQLite.get_entry_instances_by_url_hash(db_file, url_hash) - entry = {'title' : entry['title'], - 'link' : entry['link'], - 'summary' : entry['summary'], - 'published' : entry['published'], - 'updated' : entry['published'], - #'updated' : entry['updated'], - 'tags' : entry['tags'], - 'url_hash' : url_hash, - 'jid' : jabber_id, - 'name' : name, - 'instances' : instances} - #message = 'Discover new links and see who shares them' - xmpp_instance = accounts[jabber_id] - payload = Syndication.create_rfc4287_entry(entry) - iq = await XmppPubsub.publish_node_item( - xmpp_instance, jabber_id, node_id, item_id, payload) - #await iq.send(timeout=15) - message = 'Blasta system message » Imported {} items.'.format(len(entries)) + counter = 0 + + for entry_type in entries: + for entry in entries[entry_type]: + url_hash = item_id = Utilities.hash_url_to_md5(entry['link']) + instances = SQLite.get_entry_instances_by_url_hash(db_file, url_hash) + entry_new = { + 'title' : entry['title'], + 'link' : entry['link'], + 'summary' : entry['summary'], + 'published' : entry['published'], + 'updated' : entry['published'], + #'updated' : entry['updated'], + 'tags' : entry['tags'], + 'url_hash' : url_hash, + 'jid' : jabber_id, + 'name' : name, + 'instances' : instances} + #message = 'Discover new links and see who shares them' + xmpp_instance = accounts[jabber_id] + payload = Syndication.create_rfc4287_entry(entry_new) + iq = await XmppPubsub.publish_node_item( + xmpp_instance, jabber_id, node_id, item_id, payload) + #await iq.send(timeout=15) + counter += 1 + + message = 'Blasta system message » Imported {} items.'.format(counter) description = 'Import successful' path = 'profile' return result_post(request, jabber_id, description, message, path) diff --git a/xhtml/profile.xhtml b/xhtml/profile.xhtml index 70f2a34..439e935 100644 --- a/xhtml/profile.xhtml +++ b/xhtml/profile.xhtml @@ -117,10 +117,10 @@
Choose the desired @@ -250,25 +253,24 @@ merge tags.">