strip all absolute paths from stored profile images
the build was successful Details

This commit is contained in:
Dan Ballard 2020-01-20 13:14:48 -08:00
parent 449bccd626
commit 94f5dd20bd
6 changed files with 21 additions and 12 deletions

1
go.sum
View File

@ -79,6 +79,7 @@ golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190420181800-aa740d480789 h1:FF0rjo15h51+N6642mf5S3QuplmKo2aCrJUYkHTx85s=
golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=

View File

@ -602,7 +602,7 @@ func (this *GrandCentralDispatcher) loadProfile(onion string) {
pic = RandomProfileImage(the.Peer.GetProfile().Onion)
the.Peer.SetAttribute(constants.Picture, pic)
}
this.UpdateMyProfile(the.Peer.GetProfile().Name, the.Peer.GetProfile().Onion, pic)
this.UpdateMyProfile(the.Peer.GetProfile().Name, the.Peer.GetProfile().Onion, profilePicRelativize(pic))
contacts := the.Peer.GetContacts()
for i := range contacts {

View File

@ -8,6 +8,7 @@ import (
"cwtch.im/ui/go/the"
"git.openprivacy.ca/openprivacy/libricochet-go/log"
"runtime/debug"
"strings"
"time"
)
@ -62,11 +63,18 @@ func initLastReadTime(id string) time.Time {
return lastRead
}
// a lot of pics were stored full path + uri. remove all this to the relative path in images/
// fix for storing full paths introduced 2019.12
func profilePicRelativize(filename string) string {
parts := strings.Split(filename, "qml/images")
return parts[len(parts)-1]
}
func initProfilePicture(id string) string {
if isGroup(id) {
return getWithSetDefault(id, constants.Picture, RandomGroupImage(id))
return profilePicRelativize(getWithSetDefault(id, constants.Picture, RandomGroupImage(id)))
} else {
return getWithSetDefault(id, constants.Picture, RandomProfileImage(id))
return profilePicRelativize(getWithSetDefault(id, constants.Picture, RandomProfileImage(id)))
}
}
@ -76,11 +84,11 @@ func getProfilePic(id string) string {
if pic, exists := the.Peer.GetGroupAttribute(id, constants.Picture); !exists {
return RandomGroupImage(id)
} else {
return pic
return profilePicRelativize(pic)
}
} else {
if pic, exists := the.Peer.GetContactAttribute(id, constants.Picture); !exists {
return RandomProfileImage(id)
return profilePicRelativize(RandomProfileImage(id))
} else {
return pic
}
@ -125,8 +133,8 @@ func AddProfile(gcd *GrandCentralDispatcher, handle string) {
}
tag, _ := peer.GetAttribute(app.AttributeTag)
log.Infof("AddProfile %v %v %v %v\n", handle, nick, pic, tag)
gcd.AddProfile(handle, nick, pic, tag)
log.Infof("AddProfile %v %v %v %v\n", handle, nick, profilePicRelativize(pic), tag)
gcd.AddProfile(handle, nick, profilePicRelativize(pic), tag)
}
}

View File

@ -13,7 +13,7 @@ func RandomProfileImage(onion string) string {
barr, err := base32.StdEncoding.DecodeString(strings.ToUpper(onion))
if err != nil || len(barr) != 35 {
log.Errorf("error: %v %v %v\n", onion, err, barr)
return "qrc:/qml/images/extra/openprivacy.png"
return "extra/openprivacy.png"
}
return "profiles/" + choices[int(barr[33])%len(choices)] + ".png"
}
@ -23,7 +23,7 @@ func RandomGroupImage(handle string) string {
barr, err := hex.DecodeString(handle)
if err != nil || len(barr) == 0 {
log.Errorf("error: %v %v %v\n", handle, err, barr)
return "qrc:/qml/images/extra/openprivacy.png"
return "extra/openprivacy.png"
}
return "servers/" + choices[int(barr[0])%len(choices)] + ".png"
}

View File

@ -118,7 +118,7 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
Image {// Profle Type
id: profiletype
source: tag == "v1-userPassword" ? "qrc:/qml/images/fontawesome/solid/lock.svg" : "qrc:/qml/images/fontawesome/solid/lock-open.svg"
source: tag == "v1-userPassword" ? gcd.assetPath + "/fontawesome/solid/lock.svg" : gcd.assetPath + "/fontawesome/solid/lock-open.svg"
anchors.right: parent.right

View File

@ -86,7 +86,7 @@ ColumnLayout {
profilesModel.append({
_handle: "",
_displayName: qsTr("add-new-profile-btn"),
_image: "qrc:/qml/images/fontawesome/solid/user-plus.svg",
_image: "/fontawesome/solid/user-plus.svg",
_type: "button",
_tag: ","
})
@ -99,7 +99,7 @@ ColumnLayout {
ListElement {
_handle: ""
_displayName: qsTr("add-new-profile-btn")
_image: "qrc:/qml/images/fontawesome/solid/user-plus.svg"
_image: "/fontawesome/solid/user-plus.svg"
_type: "button"
_tag: ""
}