libCwtch-go changes for storage engine refactor and profile api changes #47
Loading…
Reference in New Issue
No description provided.
Delete Branch "cwtch_refactor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Significant refactor, see cwtch.im/cwtch#404
This removes a lot of functionality that has been moved to cwtch.
manager.go
all enhancement now takes place in the event HandlerPeerCreated
is nowContactCreated
Still a work in progress, but offered here for comments as it impacts the review of the cwtch pr
@ -12,2 +13,4 @@
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect
)
replace cwtch.im/cwtch => /home/sarah/workspace/src/cwtch.im/cwtch
not in final
@ -615,2 +520,2 @@
}))
}
messages, err := profile.GetMostRecentMessages(conversationID, 0, messageIndex, 1)
if err == nil && len(messages) == 1 {
this could have more than 1 message returned? then what do we do?
seems like a missmatch always needing/only handing one message calling an interface that can return N?
This is the future-proofed getNMessages API.
It literally can't
profile.GetMostRecentMessages(conversationID, 0, messageIndex, **1**)
@ -650,0 +556,4 @@
if message.ID == id {
time, _ := time.Parse(time.RFC3339Nano, messages[0].Attr[constants2.AttrSentTimestamp])
msg := model.Message{
Message: messages[0].Body,
doesnt this make 100 coopies of message 0?
why fo we get messages back in a format we have to process and migrate data from?
UI renders messages by row numberCwtch understands messages by message id.
For quoted messages we therefore need a mapping between the actual database row and the message ID. ContentHash gets us the ID. We don't want Row() to query the whole database and so we just look back over the most recent message - so 100 rows is chosen as a suitable limit.
I think ultimately we are going to have to push back quoted messages into Cwtch and just do the rendered there instead of in UI but I didn't want to mess too much with the API in this PR.
@ -277,1 +272,4 @@
}
lastMessage, _ := profile.GetMostRecentMessages(conversationID, 0, 0, 1)
ev.Event.Data["unread"] = strconv.Itoa(1) // we've just created this contact so by definition this must be 1...
did we just copy the EnrichNewPeer function into place here?
yes
Drone Build Status: failure
https://build.openprivacy.ca/cwtch.im/libcwtch-go/148
@ -511,4 +466,0 @@
RejectInvite(C.GoStringN(profilePtr, profileLen), C.GoStringN(handlePtr, handleLen))
}
// RejectInvite rejects a group invite
How are we handeling rejecting invites?
@ -252,4 +254,0 @@
contactList := application.GetPeer(profileOnion).GetContacts()
for _, handle := range contactList {
totalMessages := application.GetPeer(profileOnion).GetContact(handle).Timeline.Len() + len(application.GetPeer(profileOnion).GetContact(handle).UnacknowledgedMessages)
eventHandler.Push(event.NewEvent(event.MessageCounterResync, map[event.Field]string{
this event is still defined in cwtch/event/common but seems unused. is the UI migrating off this functionality? or do we need to port it into Cwtch?
@ -269,1 +256,4 @@
for _, conversation := range conversations {
if (conversation.IsGroup() && groupHandler != nil) || conversation.IsServer() == false {
totalMessages, _ := profile.GetChannelMessageCount(conversation.ID, 0)
eventHandler.Push(event.NewEvent(event.MessageCounterResync, map[event.Field]string{
we're still doing it for groups
@ -647,3 +550,1 @@
indexedMessages, err = timeline.GetMessagesByHash(contentHash)
if err != nil {
indexedMessages = []model.LocallyIndexedMessage{}
id, err := profile.GetChannelMessageByContentHash(handle, 0, contentHash)
GetMessagesByContentHash why is it looping through the most recent 100 messages?
peer.GetChannelMessageByContentHash doesnt return the message? just hte id? and then we fetch only the most recent 100 messages and iteratively search through them for it? seems like a bad API? can't we push this way into Cwtch and storage?
@ -63,3 +64,2 @@
return eh.handleAppBusEvent(&e)
case ev := <-eh.profileEvents:
return eh.handleProfileEvent(&ev)
default:
why a default in the select with appChan with a nested select with appChan again and profileEvents?
@ -243,3 +236,3 @@
ph := NewPeerHelper(peer)
profile := eh.app.GetPeer(ev.Profile)
log.Debugf("New Profile Event to Handle: %v", ev)
switch ev.Event.EventType {
it's also not being handled by the UI. is the app responding to it?
options:
case
handler justreturn
so it doesnt get queued and sent to UI till we do handle it here@ -265,0 +246,4 @@
// TODO This Conversation May Not Exist Yet...But we are not in charge of creating it...
log.Errorf("todo wait for contact to be added before processing this event...")
}
ev.Event.Data["Nick"], _ = ci.GetAttribute(attr.PublicScope, attr.ProfileZone, constants.Name)
ph.GetNick checks Local.Name first and then falls back to Peer.Name so that we can locally rename a contact. the current code now always uses the remote peer's name ignoring local renames. this breaks existing functionality
@ -269,1 +254,3 @@
peer.SetGroupAttribute(ev.Event.Data[event.GroupID], attr.GetLocalScope(constants2.Archived), event.False)
ci, err := profile.FetchConversationInfo(ev.Event.Data["RemotePeer"])
if ci != nil && err == nil {
ev.Event.Data["Nick"], _ = ci.GetAttribute(attr.PublicScope, attr.ProfileZone, constants.Name)
same. ph.Nick regressoin
@ -265,0 +264,4 @@
var exists bool
ev.Event.Data["Nick"], exists = ci.GetAttribute(attr.LocalScope, attr.ProfileZone, constants.Name)
if !exists {
ev.Event.Data["Nick"], _ = ci.GetAttribute(attr.PublicScope, attr.ProfileZone, constants.Name)
fall back to handle if we don't have a public.profile.name?
@ -270,0 +275,4 @@
var exists bool
ev.Event.Data["Nick"], exists = ci.GetAttribute(attr.LocalScope, attr.ProfileZone, constants.Name)
if !exists {
ev.Event.Data["Nick"], _ = ci.GetAttribute(attr.PublicScope, attr.ProfileZone, constants.Name)
fall back to handle if neither exist. in a group setting we are very likely not to be peered with everyone (there for unable to fetch names)
WIP: libCwtch-go changes for storage engine refactor and profile api changesto libCwtch-go changes for storage engine refactor and profile api changesDrone Build Status: failure
https://build.openprivacy.ca/cwtch.im/libcwtch-go/158
Drone Build Status: success
https://build.openprivacy.ca/cwtch.im/libcwtch-go/159
lgtm just the question about GetNextEvent() having nested select statements?