master
marxzuckerburg 4 years ago
parent 25a0f165cd
commit ca200015f2

@ -371,7 +371,7 @@ class LoginScreen(BaseScreen):
## PRIVATE KEY ## PRIVATE KEY
await logfunc(f"(2) Your PRIVATE encryption key, on the other hand, will be stored only on your device hardware. Do not share it with anyone or across any network whatsoever.") await logfunc(f"Your PRIVATE encryption key, on the other hand, will be stored only on your device hardware. Do not share it with anyone or across any network whatsoever.")
await logfunc(f"In fact this private encryption is so sensitive we'll encrypt it before storing it on your device.",pause=True,use_prefix=False) await logfunc(f"In fact this private encryption is so sensitive we'll encrypt it before storing it on your device.",pause=True,use_prefix=False)
passphrase = await self.app.get_input('Please enter a memorable password.',get_pass=True) passphrase = await self.app.get_input('Please enter a memorable password.',get_pass=True)

@ -327,9 +327,7 @@ class PostScreen(ProtectedScreen):
res = await self.app.comrad.post_async(content) res = await self.app.comrad.post_async(content)
self.log('GOT BACK RES:',res) self.log('GOT BACK RES:',res)
if res.get('res_posts',{}).get('success'):
id2post=res.get('res_posts',{}).get('posts',{})
self.app.comrad.save_posts(id2post)
import time import time
self.close_dialog() self.close_dialog()

@ -264,10 +264,10 @@ class ProfileScreen(ProtectedScreen):
# self.author_desc.halign='left' # self.author_desc.halign='left'
## Pronouns ## Pronouns
self.author_pronouns = AuthorPronouns(label='he/him',icon='gender-transgender') self.author_pronouns = AuthorPronouns(label='they/them',icon='gender-transgender')
## AUTHOR PLACE ## AUTHOR PLACE
self.author_place = AuthorPlace(label='Earth',icon='map-marker-outline') self.author_place = AuthorPlace(label='Deterritorialized',icon='map-marker-outline')
## Website ## Website
self.author_website = AuthorWebsite(label='website.org', icon='link-variant') self.author_website = AuthorWebsite(label='website.org', icon='link-variant')
@ -309,19 +309,24 @@ class ProfileScreen(ProtectedScreen):
asyncio.create_task(self.add_author_posts()) asyncio.create_task(self.add_author_posts())
async def add_author_posts(self): async def add_author_posts(self):
# add posts
lim=25 lim=25
posts=await self.app.get_my_posts()
self.log('POSTS!?',posts) posts=self.app.comrad.sent_posts()
# stop
for i,post in enumerate(posts): for i,post in enumerate(posts):
if i>lim: break if i>lim: break
data = {
post_obj = PostCard(post) 'author':post.from_name,
self.log(post) 'to_name':post.to_name,
'content':post.msg.get('txt') if type(post.msg)==dict else str(post.msg),
'timestamp':post.timestamp
}
post_obj = PostCard(data)
self.log('sent post!',post)
self.posts.append(post_obj) self.posts.append(post_obj)
self.carousel.add_widget(post_obj) self.carousel.add_widget(post_obj)
# def on_touch_move(self, ent): # def on_touch_move(self, ent):
# if self.carousel.index: # if self.carousel.index:
# self.author_name.text='moved!' # self.author_name.text='moved!'

@ -199,7 +199,7 @@ class ComradX(Caller):
# clear_screen() # clear_screen()
logfunc('Great. Comrad @Operator now has your name and public key on file (and nothing else!).',pause=True,clear=True) logfunc('Great. Comrad @Operator now has your name and public key on file (and nothing else!).',pause=True,clear=True)
logfunc(f"(2) Your PRIVATE key, on the other hand, must be stored only on your device hardware.",pause=True) logfunc(f"Your PRIVATE key, on the other hand, must be stored only on your device hardware.",pause=True)
logfunc('''Your private key is so sensitive we'll even encrypt it before storing it.''',pause=True,use_prefix=False) logfunc('''Your private key is so sensitive we'll even encrypt it before storing it.''',pause=True,use_prefix=False)
@ -502,6 +502,13 @@ class ComradX(Caller):
route='deliver_msg' route='deliver_msg'
) )
self.log('-->',res) self.log('-->',res)
# if successful
if res.get('success'):
# add to outbox
post_id = res.get('post_id')
if post_id:
self.add_to_msg_outbox(post_id)
return res return res
#def post(self,something): #def post(self,something):
@ -560,9 +567,36 @@ class ComradX(Caller):
}, },
route='deliver_post' route='deliver_post'
) )
self.log('post res from Op <-',res_op) self.log('post res from Op <-',res_op)
# if successful
if res_op.get('success'):
# add to outbox
post_id = res_op.get('post_id')
if post_id:
self.add_to_post_outbox(post_id)
# any posts to save right now?
if res_op.get('res_posts',{}).get('success'):
id2post=res_op.get('res_posts',{}).get('posts',{})
if id2post:
self.save_posts(id2post)
# stop
return res_op return res_op
def add_to_post_outbox(self,post_id):
outbox = self.get_inbox_crypt(prefix='/outbox/post/')
outbox.prepend(post_id)
self.log('added to outbox:',post_id,outbox.values)
return {'success':True,'status':'Added {post_id} to outbox for posts.'}
def add_to_msg_outbox(self,post_id):
outbox = self.get_inbox_crypt(prefix='/outbox/msg/')
outbox.prepend(post_id)
self.log('added to outbox for msgs:',post_id,outbox.values)
return {'success':True,'status':'Added {post_id} to outbox for messages.'}
@property @property
def login_details(self): def login_details(self):
@ -612,7 +646,7 @@ class ComradX(Caller):
inbox_prefix='/inbox/', inbox_prefix='/inbox/',
post_prefix='/post/' post_prefix='/post/'
) )
## Getting updates ## Getting updates
async def get_updates(self,include_posts=True): async def get_updates(self,include_posts=True):
# get any parameters we need # get any parameters we need
@ -689,12 +723,16 @@ class ComradX(Caller):
return len(self.messages()) return len(self.messages())
def sent_posts(self):
return self.posts(inbox_prefix='/outbox/post/')
def sent_messages(self):
return self.messages(inbox_prefix='/outbox/msg/')
def posts(self, def posts(self,
unread=None, unread=None,
inbox_prefix='/inbox/'): inbox_prefix='/feed/'):
inbox_prefix='/feed/'
inbox=self.get_inbox_crypt(prefix=inbox_prefix).values inbox=self.get_inbox_crypt(prefix=inbox_prefix).values
read=self.get_inbox_crypt(prefix=inbox_prefix+'read/').values read=self.get_inbox_crypt(prefix=inbox_prefix+'read/').values
self.log('post index<-',inbox) self.log('post index<-',inbox)

Loading…
Cancel
Save