#5 feature/dockerize-server

Merged
tovi merged 3 commits from feature/dockerize-server into develop 2 years ago
  1. +2
    -2
      Backend/Api/Auth/ChangeUserMessageExpiry.go
  2. +1
    -1
      Backend/Api/Auth/ChangeUserMessageExpiry_test.go
  3. +137
    -0
      Backend/Api/Friends/AcceptFriendRequest_test.go
  4. +204
    -0
      Backend/Api/Friends/CreateFriendRequest_test.go
  5. +0
    -60
      Backend/Api/Friends/FriendRequest.go
  6. +6
    -6
      Backend/Api/Friends/Friends_test.go
  7. +74
    -0
      Backend/Api/Messages/ChangeConversationMessageExpiry.go
  8. +5
    -0
      Backend/Api/Messages/Conversations.go
  9. +6
    -8
      Backend/Api/Messages/CreateMessage.go
  10. +2
    -1
      Backend/Api/Routes.go
  11. +15
    -15
      Backend/Database/ConversationDetails.go
  12. +4
    -4
      Backend/Database/Seeder/FriendSeeder.go
  13. +3
    -5
      Backend/Dockerfile
  14. +16
    -0
      Backend/Dockerfile.prod
  15. +7
    -5
      Backend/Models/Conversations.go
  16. +70
    -0
      Backend/Models/MessageExpiry.go
  17. +6
    -78
      Backend/Models/Users.go
  18. +8
    -0
      Backend/dev.sh
  19. BIN
      Backend/main
  20. +11
    -12
      README.md
  21. +1
    -1
      docker-compose.yml
  22. +1
    -1
      mobile/ios/Flutter/AppFrameworkInfo.plist
  23. +1
    -0
      mobile/ios/Flutter/Debug.xcconfig
  24. +1
    -0
      mobile/ios/Flutter/Release.xcconfig
  25. +41
    -0
      mobile/ios/Podfile
  26. +59
    -0
      mobile/ios/Podfile.lock
  27. +71
    -3
      mobile/ios/Runner.xcodeproj/project.pbxproj
  28. +3
    -0
      mobile/ios/Runner.xcworkspace/contents.xcworkspacedata
  29. +2
    -0
      mobile/ios/Runner/Info.plist
  30. +9
    -0
      mobile/lib/models/conversations.dart
  31. +1
    -2
      mobile/lib/models/my_profile.dart
  32. +1
    -1
      mobile/lib/models/text_messages.dart
  33. +3
    -1
      mobile/lib/utils/storage/conversations.dart
  34. +2
    -1
      mobile/lib/utils/storage/database.dart
  35. +1
    -1
      mobile/lib/utils/storage/messages.dart
  36. +2
    -2
      mobile/lib/views/authentication/login.dart
  37. +9
    -2
      mobile/lib/views/main/conversation/detail.dart
  38. +54
    -15
      mobile/lib/views/main/conversation/settings.dart
  39. +1
    -1
      mobile/lib/views/main/profile/change_password.dart
  40. +11
    -5
      mobile/lib/views/main/profile/profile.dart
  41. +12
    -19
      mobile/pubspec.lock
  42. +1
    -1
      mobile/pubspec.yaml

Backend/Api/Auth/ChangeMessageExpiry.go → Backend/Api/Auth/ChangeUserMessageExpiry.go View File


Backend/Api/Auth/ChangeMessageExpiry_test.go → Backend/Api/Auth/ChangeUserMessageExpiry_test.go View File


+ 137
- 0
Backend/Api/Friends/AcceptFriendRequest_test.go View File

@ -0,0 +1,137 @@
package Friends_test
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"testing"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Database"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Database/Seeder"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Models"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Tests"
)
func Test_AcceptFriendRequest(t *testing.T) {
client, ts, err := Tests.InitTestEnv()
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
u, err := Database.GetUserByUsername("test")
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
u2, err := Tests.InitTestCreateUser("test2")
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
key, err := Seeder.GenerateAesKey()
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
decodedPublicKey := Seeder.GetPubKey()
encPublicKey, err := key.AesEncrypt([]byte(Seeder.PublicKey))
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
friendReq := Models.FriendRequest{
UserID: u.ID,
FriendID: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(
[]byte(u2.ID.String()),
decodedPublicKey,
),
),
FriendUsername: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(
[]byte(u2.Username),
decodedPublicKey,
),
),
FriendPublicAsymmetricKey: base64.StdEncoding.EncodeToString(
encPublicKey,
),
SymmetricKey: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(key.Key, decodedPublicKey),
),
}
err = Database.CreateFriendRequest(&friendReq)
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
friendReqResponse := Models.FriendRequest{
UserID: u2.ID,
FriendID: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(
[]byte(u.ID.String()),
decodedPublicKey,
),
),
FriendUsername: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(
[]byte(u.Username),
decodedPublicKey,
),
),
FriendPublicAsymmetricKey: base64.StdEncoding.EncodeToString(
encPublicKey,
),
SymmetricKey: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(key.Key, decodedPublicKey),
),
}
jsonStr, _ := json.Marshal(friendReqResponse)
req, _ := http.NewRequest(
"POST",
fmt.Sprintf(
"%s/api/v1/auth/friend_request/%s",
ts.URL,
friendReq.ID,
),
bytes.NewBuffer(jsonStr),
)
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
if resp.StatusCode != http.StatusNoContent {
t.Errorf("Expected %d, recieved %d", http.StatusNoContent, resp.StatusCode)
return
}
var reqs []Models.FriendRequest
err = Database.DB.Find(&reqs).Error
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
for _, r := range reqs {
if r.AcceptedAt.Valid != true {
t.Errorf("Expected true, recieved false")
return
}
}
}

+ 204
- 0
Backend/Api/Friends/CreateFriendRequest_test.go View File

@ -0,0 +1,204 @@
package Friends_test
import (
"bytes"
"encoding/base64"
"encoding/json"
"net/http"
"testing"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Database"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Database/Seeder"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Models"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Tests"
)
func Test_CreateFriendRequest(t *testing.T) {
client, ts, err := Tests.InitTestEnv()
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
u, err := Database.GetUserByUsername("test")
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
u2, err := Tests.InitTestCreateUser("test2")
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
key, err := Seeder.GenerateAesKey()
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
decodedPublicKey := Seeder.GetPubKey()
encPublicKey, err := key.AesEncrypt([]byte(Seeder.PublicKey))
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
friendReq := Models.FriendRequest{
UserID: u.ID,
FriendID: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(
[]byte(u2.ID.String()),
decodedPublicKey,
),
),
FriendUsername: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(
[]byte(u2.Username),
decodedPublicKey,
),
),
FriendPublicAsymmetricKey: base64.StdEncoding.EncodeToString(
encPublicKey,
),
SymmetricKey: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(key.Key, decodedPublicKey),
),
}
jsonStr, _ := json.Marshal(friendReq)
req, _ := http.NewRequest("POST", ts.URL+"/api/v1/auth/friend_request", bytes.NewBuffer(jsonStr))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
if resp.StatusCode != http.StatusOK {
t.Errorf("Expected %d, recieved %d", http.StatusOK, resp.StatusCode)
return
}
var r Models.FriendRequest
err = Database.DB.First(&r).Error
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
if r.AcceptedAt.Valid == true {
t.Errorf("Expected false, recieved true")
return
}
}
func Test_CreateFriendRequestQrCode(t *testing.T) {
client, ts, err := Tests.InitTestEnv()
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
u, err := Database.GetUserByUsername("test")
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
u2, err := Tests.InitTestCreateUser("test2")
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
key, err := Seeder.GenerateAesKey()
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
decodedPublicKey := Seeder.GetPubKey()
encPublicKey, err := key.AesEncrypt([]byte(Seeder.PublicKey))
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
friendReq := Models.FriendRequest{
UserID: u.ID,
FriendID: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(
[]byte(u2.ID.String()),
decodedPublicKey,
),
),
FriendUsername: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(
[]byte(u2.Username),
decodedPublicKey,
),
),
FriendPublicAsymmetricKey: base64.StdEncoding.EncodeToString(
encPublicKey,
),
SymmetricKey: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(key.Key, decodedPublicKey),
),
}
friendReq2 := Models.FriendRequest{
UserID: u2.ID,
FriendID: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(
[]byte(u.ID.String()),
decodedPublicKey,
),
),
FriendUsername: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(
[]byte(u.Username),
decodedPublicKey,
),
),
FriendPublicAsymmetricKey: base64.StdEncoding.EncodeToString(
encPublicKey,
),
SymmetricKey: base64.StdEncoding.EncodeToString(
Seeder.EncryptWithPublicKey(key.Key, decodedPublicKey),
),
}
jsonStr, _ := json.Marshal([]Models.FriendRequest{friendReq, friendReq2})
req, _ := http.NewRequest("POST", ts.URL+"/api/v1/auth/friend_request/qr_code", bytes.NewBuffer(jsonStr))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
if resp.StatusCode != http.StatusOK {
t.Errorf("Expected %d, recieved %d", http.StatusOK, resp.StatusCode)
return
}
var r Models.FriendRequest
err = Database.DB.First(&r).Error
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
if r.AcceptedAt.Valid == false {
t.Errorf("Expected true, recieved false")
return
}
}

+ 0
- 60
Backend/Api/Friends/FriendRequest.go View File

@ -1,60 +0,0 @@
package Friends
import (
"encoding/json"
"io/ioutil"
"net/http"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Database"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Models"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Util"
)
func FriendRequest(w http.ResponseWriter, r *http.Request) {
var (
user Models.User
requestBody []byte
requestJson map[string]interface{}
friendID string
friendRequest Models.FriendRequest
ok bool
err error
)
user, err = Util.GetUserById(w, r)
if err != nil {
http.Error(w, "Not Found", http.StatusNotFound)
return
}
requestBody, err = ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "Not Found", http.StatusNotFound)
return
}
json.Unmarshal(requestBody, &requestJson)
if requestJson["id"] == nil {
http.Error(w, "Invalid Data", http.StatusBadRequest)
return
}
friendID, ok = requestJson["id"].(string)
if !ok {
http.Error(w, "Error", http.StatusInternalServerError)
return
}
friendRequest = Models.FriendRequest{
UserID: user.ID,
FriendID: friendID,
}
err = Database.CreateFriendRequest(&friendRequest)
if requestJson["id"] == nil {
http.Error(w, "Error", http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusNoContent)
}

+ 6
- 6
Backend/Api/Friends/Friends_test.go View File

@ -28,17 +28,17 @@ func Test_FriendRequestList(t *testing.T) {
return return
} }
key, err := Seeder.GenerateAesKey()
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
for i := 0; i < 30; i++ { for i := 0; i < 30; i++ {
u2, err := Tests.InitTestCreateUser(fmt.Sprintf("test%d", i)) u2, err := Tests.InitTestCreateUser(fmt.Sprintf("test%d", i))
decodedPublicKey := Seeder.GetPubKey() decodedPublicKey := Seeder.GetPubKey()
key, err := Seeder.GenerateAesKey()
if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error())
return
}
encPublicKey, err := key.AesEncrypt([]byte(Seeder.PublicKey)) encPublicKey, err := key.AesEncrypt([]byte(Seeder.PublicKey))
if err != nil { if err != nil {
t.Errorf("Expected nil, recieved %s", err.Error()) t.Errorf("Expected nil, recieved %s", err.Error())


+ 74
- 0
Backend/Api/Messages/ChangeConversationMessageExpiry.go View File

@ -0,0 +1,74 @@
package Messages
import (
"encoding/json"
"io/ioutil"
"net/http"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Database"
"git.tovijaeschke.xyz/tovi/Capsule/Backend/Models"
"github.com/gorilla/mux"
)
type rawChangeMessageExpiry struct {
MessageExpiry string `json:"message_expiry"`
}
// ChangeUserMessageExpiry handles changing default message expiry for user
func ChangeConversationMessageExpiry(w http.ResponseWriter, r *http.Request) {
var (
// user Models.User
changeMessageExpiry rawChangeMessageExpiry
conversationDetail Models.ConversationDetail
requestBody []byte
urlVars map[string]string
detailID string
ok bool
err error
)
urlVars = mux.Vars(r)
detailID, ok = urlVars["detailID"]
if !ok {
http.Error(w, "Not Found", http.StatusNotFound)
return
}
conversationDetail, err = Database.GetConversationDetailByID(detailID)
if err != nil {
http.Error(w, "Not Found", http.StatusNotFound)
return
}
// Ignore error here, as middleware should handle auth
// TODO: Check if user in conversation
// user, _ = Auth.CheckCookieCurrentUser(w, r)
requestBody, err = ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
return
}
err = json.Unmarshal(requestBody, &changeMessageExpiry)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
return
}
err = conversationDetail.MessageExpiryDefault.Scan(changeMessageExpiry.MessageExpiry)
if err != nil {
http.Error(w, "Error", http.StatusUnprocessableEntity)
return
}
err = Database.UpdateConversationDetail(
&conversationDetail,
)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusNoContent)
}

+ 5
- 0
Backend/Api/Messages/Conversations.go View File

@ -1,6 +1,7 @@
package Messages package Messages
import ( import (
"database/sql/driver"
"encoding/json" "encoding/json"
"net/http" "net/http"
"net/url" "net/url"
@ -58,6 +59,7 @@ func ConversationDetailsList(w http.ResponseWriter, r *http.Request) {
detail Models.ConversationDetail detail Models.ConversationDetail
query url.Values query url.Values
conversationIds []string conversationIds []string
messageExpiryRaw driver.Value
returnJSON []byte returnJSON []byte
i int i int
ok bool ok bool
@ -82,6 +84,9 @@ func ConversationDetailsList(w http.ResponseWriter, r *http.Request) {
} }
for i, detail = range conversationDetails { for i, detail = range conversationDetails {
messageExpiryRaw, _ = detail.MessageExpiryDefault.Value()
conversationDetails[i].MessageExpiry, _ = messageExpiryRaw.(string)
if detail.AttachmentID == nil { if detail.AttachmentID == nil {
continue continue
} }


+ 6
- 8
Backend/Api/Messages/CreateMessage.go View File

@ -44,14 +44,12 @@ func CreateMessage(w http.ResponseWriter, r *http.Request) {
for i, message = range messageData.Messages { for i, message = range messageData.Messages {
t, err = time.Parse("2006-01-02T15:04:05Z", message.ExpiryRaw) t, err = time.Parse("2006-01-02T15:04:05Z", message.ExpiryRaw)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
return
}
err = messageData.Messages[i].Expiry.Scan(t)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
return
if err == nil {
err = messageData.Messages[i].Expiry.Scan(t)
if err != nil {
http.Error(w, "Error", http.StatusInternalServerError)
return
}
} }
} }


+ 2
- 1
Backend/Api/Routes.go View File

@ -63,7 +63,7 @@ func InitAPIEndpoints(router *mux.Router) {
authAPI.HandleFunc("/check", Auth.Check).Methods("GET") authAPI.HandleFunc("/check", Auth.Check).Methods("GET")
authAPI.HandleFunc("/change_password", Auth.ChangePassword).Methods("POST") authAPI.HandleFunc("/change_password", Auth.ChangePassword).Methods("POST")
authAPI.HandleFunc("/message_expiry", Auth.ChangeMessageExpiry).Methods("POST")
authAPI.HandleFunc("/message_expiry", Auth.ChangeUserMessageExpiry).Methods("POST")
authAPI.HandleFunc("/image", Auth.AddProfileImage).Methods("POST") authAPI.HandleFunc("/image", Auth.AddProfileImage).Methods("POST")
authAPI.HandleFunc("/users", Users.SearchUsers).Methods("GET") authAPI.HandleFunc("/users", Users.SearchUsers).Methods("GET")
@ -79,6 +79,7 @@ func InitAPIEndpoints(router *mux.Router) {
authAPI.HandleFunc("/conversations", Messages.CreateConversation).Methods("POST") authAPI.HandleFunc("/conversations", Messages.CreateConversation).Methods("POST")
authAPI.HandleFunc("/conversations", Messages.UpdateConversation).Methods("PUT") authAPI.HandleFunc("/conversations", Messages.UpdateConversation).Methods("PUT")
authAPI.HandleFunc("/conversations/{detailID}/image", Messages.AddConversationImage).Methods("POST") authAPI.HandleFunc("/conversations/{detailID}/image", Messages.AddConversationImage).Methods("POST")
authAPI.HandleFunc("/conversations/{detailID}/message_expiry", Messages.ChangeConversationMessageExpiry).Methods("POST")
authAPI.HandleFunc("/message", Messages.CreateMessage).Methods("POST") authAPI.HandleFunc("/message", Messages.CreateMessage).Methods("POST")
authAPI.HandleFunc("/messages/{associationKey}", Messages.Messages).Methods("GET") authAPI.HandleFunc("/messages/{associationKey}", Messages.Messages).Methods("GET")


+ 15
- 15
Backend/Database/ConversationDetails.go View File

@ -10,51 +10,51 @@ import (
// GetConversationDetailByID gets by id // GetConversationDetailByID gets by id
func GetConversationDetailByID(id string) (Models.ConversationDetail, error) { func GetConversationDetailByID(id string) (Models.ConversationDetail, error) {
var ( var (
messageThread Models.ConversationDetail
err error
conversationDetail Models.ConversationDetail
err error
) )
err = DB.Preload(clause.Associations). err = DB.Preload(clause.Associations).
Where("id = ?", id). Where("id = ?", id).
First(&messageThread).
First(&conversationDetail).
Error Error
return messageThread, err
return conversationDetail, err
} }
// GetConversationDetailsByIds gets by multiple ids // GetConversationDetailsByIds gets by multiple ids
func GetConversationDetailsByIds(id []string) ([]Models.ConversationDetail, error) { func GetConversationDetailsByIds(id []string) ([]Models.ConversationDetail, error) {
var ( var (
messageThread []Models.ConversationDetail
err error
conversationDetail []Models.ConversationDetail
err error
) )
err = DB.Preload(clause.Associations). err = DB.Preload(clause.Associations).
Where("id IN ?", id). Where("id IN ?", id).
Find(&messageThread).
Find(&conversationDetail).
Error Error
return messageThread, err
return conversationDetail, err
} }
// CreateConversationDetail creates a ConversationDetail record // CreateConversationDetail creates a ConversationDetail record
func CreateConversationDetail(messageThread *Models.ConversationDetail) error {
func CreateConversationDetail(conversationDetail *Models.ConversationDetail) error {
return DB.Session(&gorm.Session{FullSaveAssociations: true}). return DB.Session(&gorm.Session{FullSaveAssociations: true}).
Create(messageThread).
Create(conversationDetail).
Error Error
} }
// UpdateConversationDetail updates a ConversationDetail record // UpdateConversationDetail updates a ConversationDetail record
func UpdateConversationDetail(messageThread *Models.ConversationDetail) error {
func UpdateConversationDetail(conversationDetail *Models.ConversationDetail) error {
return DB.Session(&gorm.Session{FullSaveAssociations: true}). return DB.Session(&gorm.Session{FullSaveAssociations: true}).
Where("id = ?", messageThread.ID).
Updates(messageThread).
Where("id = ?", conversationDetail.ID).
Updates(conversationDetail).
Error Error
} }
// DeleteConversationDetail deletes a ConversationDetail record // DeleteConversationDetail deletes a ConversationDetail record
func DeleteConversationDetail(messageThread *Models.ConversationDetail) error {
func DeleteConversationDetail(conversationDetail *Models.ConversationDetail) error {
return DB.Session(&gorm.Session{FullSaveAssociations: true}). return DB.Session(&gorm.Session{FullSaveAssociations: true}).
Delete(messageThread).
Delete(conversationDetail).
Error Error
} }

+ 4
- 4
Backend/Database/Seeder/FriendSeeder.go View File

@ -90,10 +90,10 @@ func SeedFriends() {
err error err error
) )
err = copyProfileImage()
if err != nil {
panic(err)
}
// err = copyProfileImage()
// if err != nil {
// panic(err)
// }
primaryUser, err = Database.GetUserByUsername("testUser") primaryUser, err = Database.GetUserByUsername("testUser")
if err != nil { if err != nil {


+ 3
- 5
Backend/Dockerfile View File

@ -6,11 +6,9 @@ COPY ./ /go/src/git.tovijaeschke.xyz/Capsule/Backend
WORKDIR /go/src/git.tovijaeschke.xyz/Capsule/Backend WORKDIR /go/src/git.tovijaeschke.xyz/Capsule/Backend
# For "go test"
RUN apk add gcc libc-dev
# For "go test" and development
RUN apk add gcc libc-dev inotify-tools
RUN go mod download RUN go mod download
RUN go build -o /go/bin/capsule-server main.go
CMD [ "/go/bin/capsule-server" ]
CMD [ "sh", "./dev.sh" ]

+ 16
- 0
Backend/Dockerfile.prod View File

@ -0,0 +1,16 @@
FROM golang:1.19-alpine
RUN mkdir -p /go/src/git.tovijaeschke.xyz/Capsule/Backend
COPY ./ /go/src/git.tovijaeschke.xyz/Capsule/Backend
WORKDIR /go/src/git.tovijaeschke.xyz/Capsule/Backend
# For "go test"
RUN apk add gcc libc-dev
RUN go mod download
RUN go build -o /go/bin/capsule-server main.go
CMD [ "/go/bin/capsule-server" ]

+ 7
- 5
Backend/Models/Conversations.go View File

@ -9,11 +9,13 @@ import (
// ConversationDetail stores the name for the conversation // ConversationDetail stores the name for the conversation
type ConversationDetail struct { type ConversationDetail struct {
Base Base
Name string `gorm:"not null" json:"name"` // Stored encrypted
Users []ConversationDetailUser ` json:"users"`
TwoUser string `gorm:"not null" json:"two_user"`
AttachmentID *uuid.UUID ` json:"attachment_id"`
Attachment Attachment ` json:"attachment"`
Name string `gorm:"not null" json:"name"` // Stored encrypted
Users []ConversationDetailUser ` json:"users"`
TwoUser string `gorm:"not null" json:"two_user"`
AttachmentID *uuid.UUID ` json:"attachment_id"`
Attachment Attachment ` json:"attachment"`
MessageExpiryDefault MessageExpiry `gorm:"default:no_expiry" json:"-" sql:"type:ENUM('fifteen_min', 'thirty_min', 'one_hour', 'three_hour', 'six_hour', 'twelve_hour', 'one_day', 'three_day', 'no_expiry')"` // Stored encrypted
MessageExpiry string `gorm:"-" json:"message_expiry"` // Stored encrypted
} }
// ConversationDetailUser all users associated with a customer // ConversationDetailUser all users associated with a customer


+ 70
- 0
Backend/Models/MessageExpiry.go View File

@ -0,0 +1,70 @@
package Models
import (
"database/sql/driver"
"errors"
)
// MessageExpiry holds values for how long messages should expire by default
type MessageExpiry []uint8
const (
// MessageExpiryFifteenMin expires after 15 minutes
MessageExpiryFifteenMin = "fifteen_min"
// MessageExpiryThirtyMin expires after 30 minutes
MessageExpiryThirtyMin = "thirty_min"
// MessageExpiryOneHour expires after one hour
MessageExpiryOneHour = "one_hour"
// MessageExpiryThreeHour expires after three hours
MessageExpiryThreeHour = "three_hour"
// MessageExpirySixHour expires after six hours
MessageExpirySixHour = "six_hour"
// MessageExpiryTwelveHour expires after twelve hours
MessageExpiryTwelveHour = "twelve_hour"
// MessageExpiryOneDay expires after one day
MessageExpiryOneDay = "one_day"
// MessageExpiryThreeDay expires after three days
MessageExpiryThreeDay = "three_day"
// MessageExpiryNoExpiry never expires
MessageExpiryNoExpiry = "no_expiry"
)
// MessageExpiryValues list of all expiry values for validation
var MessageExpiryValues = []string{
MessageExpiryFifteenMin,
MessageExpiryThirtyMin,
MessageExpiryOneHour,
MessageExpiryThreeHour,
MessageExpirySixHour,
MessageExpiryTwelveHour,
MessageExpiryOneDay,
MessageExpiryThreeDay,
MessageExpiryNoExpiry,
}
// Scan new value into MessageExpiry
func (e *MessageExpiry) Scan(value interface{}) error {
var (
strValue = value.(string)
m string
)
for _, m = range MessageExpiryValues {
if strValue != m {
continue
}
*e = MessageExpiry(strValue)
return nil
}
return errors.New("Invalid MessageExpiry value")
}
// Value gets value out of MessageExpiry column
func (e MessageExpiry) Value() (driver.Value, error) {
return string(e), nil
}
func (e MessageExpiry) String() string {
return string(e)
}

+ 6
- 78
Backend/Models/Users.go View File

@ -1,84 +1,20 @@
package Models package Models
import ( import (
"database/sql/driver"
"errors"
"github.com/gofrs/uuid" "github.com/gofrs/uuid"
"gorm.io/gorm" "gorm.io/gorm"
) )
// BeforeUpdate prevents updating the email if it has not changed
// BeforeUpdate prevents updating the username or email if it has not changed
// This stops a unique constraint error // This stops a unique constraint error
func (u *User) BeforeUpdate(tx *gorm.DB) (err error) { func (u *User) BeforeUpdate(tx *gorm.DB) (err error) {
if !tx.Statement.Changed("Username") { if !tx.Statement.Changed("Username") {
tx.Statement.Omit("Username") tx.Statement.Omit("Username")
} }
return nil
}
// MessageExpiry holds values for how long messages should expire by default
type MessageExpiry []uint8
const (
// MessageExpiryFifteenMin expires after 15 minutes
MessageExpiryFifteenMin = "fifteen_min"
// MessageExpiryThirtyMin expires after 30 minutes
MessageExpiryThirtyMin = "thirty_min"
// MessageExpiryOneHour expires after one hour
MessageExpiryOneHour = "one_hour"
// MessageExpiryThreeHour expires after three hours
MessageExpiryThreeHour = "three_hour"
// MessageExpirySixHour expires after six hours
MessageExpirySixHour = "six_hour"
// MessageExpiryTwelveHour expires after twelve hours
MessageExpiryTwelveHour = "twelve_hour"
// MessageExpiryOneDay expires after one day
MessageExpiryOneDay = "one_day"
// MessageExpiryThreeDay expires after three days
MessageExpiryThreeDay = "three_day"
// MessageExpiryNoExpiry never expires
MessageExpiryNoExpiry = "no_expiry"
)
// MessageExpiryValues list of all expiry values for validation
var MessageExpiryValues = []string{
MessageExpiryFifteenMin,
MessageExpiryThirtyMin,
MessageExpiryOneHour,
MessageExpiryThreeHour,
MessageExpirySixHour,
MessageExpiryTwelveHour,
MessageExpiryOneDay,
MessageExpiryThreeDay,
MessageExpiryNoExpiry,
}
// Scan new value into MessageExpiry
func (e *MessageExpiry) Scan(value interface{}) error {
var (
strValue = value.(string)
m string
)
for _, m = range MessageExpiryValues {
if strValue != m {
continue
}
*e = MessageExpiry(strValue)
return nil
if !tx.Statement.Changed("Email") {
tx.Statement.Omit("Email")
} }
return errors.New("Invalid MessageExpiry value")
}
// Value gets value out of MessageExpiry column
func (e MessageExpiry) Value() (driver.Value, error) {
return string(e), nil
}
func (e MessageExpiry) String() string {
return string(e)
return nil
} }
// User holds user data // User holds user data
@ -87,19 +23,11 @@ type User struct {
Username string `gorm:"not null;unique" json:"username"` Username string `gorm:"not null;unique" json:"username"`
Password string `gorm:"not null" json:"password"` Password string `gorm:"not null" json:"password"`
ConfirmPassword string `gorm:"-" json:"confirm_password"` ConfirmPassword string `gorm:"-" json:"confirm_password"`
Email string ` json:"email"`
AsymmetricPrivateKey string `gorm:"not null" json:"asymmetric_private_key"` // Stored encrypted AsymmetricPrivateKey string `gorm:"not null" json:"asymmetric_private_key"` // Stored encrypted
AsymmetricPublicKey string `gorm:"not null" json:"asymmetric_public_key"` AsymmetricPublicKey string `gorm:"not null" json:"asymmetric_public_key"`
SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted
AttachmentID *uuid.UUID ` json:"attachment_id"` AttachmentID *uuid.UUID ` json:"attachment_id"`
Attachment Attachment ` json:"attachment"` Attachment Attachment ` json:"attachment"`
MessageExpiryDefault MessageExpiry `gorm:"default:no_expiry" json:"-" sql:"type:ENUM(
'fifteen_min',
'thirty_min',
'one_hour',
'three_hour',
'six_hour',
'twelve_hour',
'one_day',
'three_day'
)"` // Stored encrypted
MessageExpiryDefault MessageExpiry `gorm:"default:no_expiry" json:"-" sql:"type:ENUM('fifteen_min', 'thirty_min', 'one_hour', 'three_hour', 'six_hour', 'twelve_hour', 'one_day', 'three_day', 'no_expiry')"` // Stored encrypted
} }

+ 8
- 0
Backend/dev.sh View File

@ -0,0 +1,8 @@
#!/bin/sh
while true; do
go build main.go
./main &
PID=$!
inotifywait -r -e modify .
kill $PID
done

BIN
Backend/main View File


+ 11
- 12
README.md View File

@ -4,15 +4,14 @@ Encrypted messaging app
## TODO ## TODO
[x] Fix adding users to conversations
[x] Fix users recieving messages
[x] Fix the admin checks on conversation settings page
[x] Fix sending messages in a conversation that includes users that are not the current users friend
[x] Add admin checks to conversation settings page
[ ] Add admin checks on backend
[ ] Add errors to login / signup page
[ ] Add errors when updating conversations
[ ] Refactor the update conversations function
[ ] Finish the friends list page
[ ] Allow adding friends
[ ] Finish the disappearing messages functionality
- Fix friends list search
- Add friends profile picture
- Add conversation pagination
- Add message pagination
- Add message pagination
- Finish off conversation settings page
- Finish message expiry
- Add back button to QR scanner
- Add more padding at message send text box
- Fix error when creating existing conversation between friends
- Sort conversation based on latest message

+ 1
- 1
docker-compose.yml View File

@ -7,7 +7,7 @@ services:
ports: ports:
- "8080:8080" - "8080:8080"
volumes: volumes:
- "./Backend:/app"
- "./Backend:/go/src/git.tovijaeschke.xyz/Capsule/Backend"
links: links:
- postgres - postgres
- postgres-testing - postgres-testing


+ 1
- 1
mobile/ios/Flutter/AppFrameworkInfo.plist View File

@ -21,6 +21,6 @@
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.0</string> <string>1.0</string>
<key>MinimumOSVersion</key> <key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict> </dict>
</plist> </plist>

+ 1
- 0
mobile/ios/Flutter/Debug.xcconfig View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig" #include "Generated.xcconfig"

+ 1
- 0
mobile/ios/Flutter/Release.xcconfig View File

@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig" #include "Generated.xcconfig"

+ 41
- 0
mobile/ios/Podfile View File

@ -0,0 +1,41 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end

+ 59
- 0
mobile/ios/Podfile.lock View File

@ -0,0 +1,59 @@
PODS:
- Flutter (1.0.0)
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- image_picker_ios (0.0.1):
- Flutter
- MTBBarcodeScanner (5.0.11)
- path_provider_ios (0.0.1):
- Flutter
- qr_code_scanner (0.2.0):
- Flutter
- MTBBarcodeScanner
- shared_preferences_ios (0.0.1):
- Flutter
- sqflite (0.0.2):
- Flutter
- FMDB (>= 2.7.5)
DEPENDENCIES:
- Flutter (from `Flutter`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
- qr_code_scanner (from `.symlinks/plugins/qr_code_scanner/ios`)
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
SPEC REPOS:
trunk:
- FMDB
- MTBBarcodeScanner
EXTERNAL SOURCES:
Flutter:
:path: Flutter
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
path_provider_ios:
:path: ".symlinks/plugins/path_provider_ios/ios"
qr_code_scanner:
:path: ".symlinks/plugins/qr_code_scanner/ios"
shared_preferences_ios:
:path: ".symlinks/plugins/shared_preferences_ios/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
image_picker_ios: b786a5dcf033a8336a657191401bfdf12017dabb
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e
shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
COCOAPODS: 1.11.3

+ 71
- 3
mobile/ios/Runner.xcodeproj/project.pbxproj View File

@ -10,6 +10,7 @@
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
7C176E8E73493FDFE1D7C309 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00CA36B62CB085270A92E728 /* Pods_Runner.framework */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
@ -29,12 +30,15 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
00CA36B62CB085270A92E728 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7D2302AC69A24C6395A4B678 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
7F7E44AA84E3C88CDE6063C2 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -42,6 +46,7 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E1FB47F20CF9808436BCAA60 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -49,6 +54,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
7C176E8E73493FDFE1D7C309 /* Pods_Runner.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -72,6 +78,8 @@
9740EEB11CF90186004384FC /* Flutter */, 9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */, 97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */, 97C146EF1CF9000F007C117D /* Products */,
BF068434B7059F0CC04D9821 /* Pods */,
AA66445C27884182A5A74088 /* Frameworks */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
}; };
@ -98,6 +106,25 @@
path = Runner; path = Runner;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
AA66445C27884182A5A74088 /* Frameworks */ = {
isa = PBXGroup;
children = (
00CA36B62CB085270A92E728 /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
BF068434B7059F0CC04D9821 /* Pods */ = {
isa = PBXGroup;
children = (
7F7E44AA84E3C88CDE6063C2 /* Pods-Runner.debug.xcconfig */,
7D2302AC69A24C6395A4B678 /* Pods-Runner.release.xcconfig */,
E1FB47F20CF9808436BCAA60 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
@ -105,12 +132,14 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = ( buildPhases = (
90DE9D5E1F568436E776C753 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */, 9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */, 97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */, 97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */, 97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */, 9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
1015E9199730C97F537825AC /* [CP] Embed Pods Frameworks */,
); );
buildRules = ( buildRules = (
); );
@ -169,6 +198,23 @@
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */
1015E9199730C97F537825AC /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -183,6 +229,28 @@
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
}; };
90DE9D5E1F568436E776C753 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = { 9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -272,7 +340,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos; SUPPORTED_PLATFORMS = iphoneos;
@ -349,7 +417,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
@ -398,7 +466,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos; SUPPORTED_PLATFORMS = iphoneos;


+ 3
- 0
mobile/ios/Runner.xcworkspace/contents.xcworkspacedata View File

@ -4,4 +4,7 @@
<FileRef <FileRef
location = "group:Runner.xcodeproj"> location = "group:Runner.xcodeproj">
</FileRef> </FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace> </Workspace>

+ 2
- 0
mobile/ios/Runner/Info.plist View File

@ -53,5 +53,7 @@
<string>Upload image from camera for screen background</string> <string>Upload image from camera for screen background</string>
<key>NSMicrophoneUsageDescription</key> <key>NSMicrophoneUsageDescription</key>
<string>Post videos to profile</string> <string>Post videos to profile</string>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict> </dict>
</plist> </plist>

+ 9
- 0
mobile/lib/models/conversations.dart View File

@ -37,6 +37,7 @@ Future<Conversation> createConversation(String title, List<Friend> friends, bool
twoUser: twoUser, twoUser: twoUser,
status: ConversationStatus.pending, status: ConversationStatus.pending,
isRead: true, isRead: true,
messageExpiryDefault: 'no_expiry'
); );
await db.insert( await db.insert(
@ -161,6 +162,7 @@ Future<Conversation> getConversationById(String id) async {
status: ConversationStatus.values[maps[0]['status']], status: ConversationStatus.values[maps[0]['status']],
isRead: maps[0]['is_read'] == 1, isRead: maps[0]['is_read'] == 1,
icon: file, icon: file,
messageExpiryDefault: maps[0]['message_expiry'],
); );
} }
@ -190,6 +192,7 @@ Future<List<Conversation>> getConversations() async {
status: ConversationStatus.values[maps[i]['status']], status: ConversationStatus.values[maps[i]['status']],
isRead: maps[i]['is_read'] == 1, isRead: maps[i]['is_read'] == 1,
icon: file, icon: file,
messageExpiryDefault: maps[i]['message_expiry'] ?? 'no_expiry',
); );
}); });
} }
@ -223,6 +226,7 @@ Future<Conversation?> getTwoUserConversation(String userId) async {
twoUser: maps[0]['two_user'] == 1, twoUser: maps[0]['two_user'] == 1,
status: ConversationStatus.values[maps[0]['status']], status: ConversationStatus.values[maps[0]['status']],
isRead: maps[0]['is_read'] == 1, isRead: maps[0]['is_read'] == 1,
messageExpiryDefault: maps[0]['message_expiry'],
); );
} }
@ -236,6 +240,7 @@ class Conversation {
bool twoUser; bool twoUser;
ConversationStatus status; ConversationStatus status;
bool isRead; bool isRead;
String messageExpiryDefault = 'no_expiry';
File? icon; File? icon;
Conversation({ Conversation({
@ -247,6 +252,7 @@ class Conversation {
required this.twoUser, required this.twoUser,
required this.status, required this.status,
required this.isRead, required this.isRead,
required this.messageExpiryDefault,
this.icon, this.icon,
}); });
@ -276,6 +282,7 @@ class Conversation {
twoUser: false, twoUser: false,
status: ConversationStatus.complete, status: ConversationStatus.complete,
isRead: true, isRead: true,
messageExpiryDefault: 'no_expiry',
); );
} }
@ -321,6 +328,7 @@ class Conversation {
'name': AesHelper.aesEncrypt(symKey, Uint8List.fromList(name.codeUnits)), 'name': AesHelper.aesEncrypt(symKey, Uint8List.fromList(name.codeUnits)),
'users': await getEncryptedConversationUsers(this, symKey), 'users': await getEncryptedConversationUsers(this, symKey),
'two_user': AesHelper.aesEncrypt(symKey, Uint8List.fromList((twoUser ? 'true' : 'false').codeUnits)), 'two_user': AesHelper.aesEncrypt(symKey, Uint8List.fromList((twoUser ? 'true' : 'false').codeUnits)),
'message_expiry': messageExpiryDefault,
'user_conversations': userConversations, 'user_conversations': userConversations,
}; };
@ -358,6 +366,7 @@ class Conversation {
'status': status.index, 'status': status.index,
'is_read': isRead ? 1 : 0, 'is_read': isRead ? 1 : 0,
'file': icon != null ? icon!.path : null, 'file': icon != null ? icon!.path : null,
'message_expiry': messageExpiryDefault,
}; };
} }


+ 1
- 2
mobile/lib/models/my_profile.dart View File

@ -2,7 +2,6 @@ import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:Capsule/utils/storage/get_file.dart'; import 'package:Capsule/utils/storage/get_file.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:pointycastle/impl.dart'; import 'package:pointycastle/impl.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -11,7 +10,7 @@ import '/utils/encryption/aes_helper.dart';
import '/utils/encryption/crypto_utils.dart'; import '/utils/encryption/crypto_utils.dart';
// TODO: Replace this with the prod url when server is deployed // TODO: Replace this with the prod url when server is deployed
String defaultServerUrl = dotenv.env['SERVER_URL'] ?? 'http://192.168.1.5:8080';
String defaultServerUrl = dotenv.env['SERVER_URL'] ?? 'http://localhost:8080/';
class MyProfile { class MyProfile {
String id; String id;


+ 1
- 1
mobile/lib/models/text_messages.dart View File

@ -99,7 +99,7 @@ class TextMessage extends Message {
); );
Map<String, String> messageData = { Map<String, String> messageData = {
'id': id,
'id': messageDataId,
'data': AesHelper.aesEncrypt(symmetricKey, Uint8List.fromList(text.codeUnits)), 'data': AesHelper.aesEncrypt(symmetricKey, Uint8List.fromList(text.codeUnits)),
'sender_id': AesHelper.aesEncrypt(symmetricKey, Uint8List.fromList(senderId.codeUnits)), 'sender_id': AesHelper.aesEncrypt(symmetricKey, Uint8List.fromList(senderId.codeUnits)),
'symmetric_key': AesHelper.aesEncrypt( 'symmetric_key': AesHelper.aesEncrypt(


+ 3
- 1
mobile/lib/utils/storage/conversations.dart View File

@ -116,6 +116,8 @@ Future<void> updateConversations() async {
var conversationDetailJson = conversationsDetailsJson[i] as Map<String, dynamic>; var conversationDetailJson = conversationsDetailsJson[i] as Map<String, dynamic>;
var conversation = findConversationByDetailId(conversations, conversationDetailJson['id']); var conversation = findConversationByDetailId(conversations, conversationDetailJson['id']);
conversation.messageExpiryDefault = conversationDetailJson['message_expiry'];
conversation.twoUser = AesHelper.aesDecrypt( conversation.twoUser = AesHelper.aesDecrypt(
base64.decode(conversation.symmetricKey), base64.decode(conversation.symmetricKey),
base64.decode(conversationDetailJson['two_user']), base64.decode(conversationDetailJson['two_user']),
@ -194,7 +196,7 @@ Future<void> uploadConversation(Conversation conversation, BuildContext context)
body: jsonEncode(conversationJson), body: jsonEncode(conversationJson),
); );
if (resp.statusCode != 200) {
if (resp.statusCode != 204) {
showMessage('Failed to create conversation', context); showMessage('Failed to create conversation', context);
} }
} }


+ 2
- 1
mobile/lib/utils/storage/database.dart View File

@ -40,7 +40,8 @@ Future<Database> getDatabaseConnection() async {
two_user INTEGER, two_user INTEGER,
status INTEGER, status INTEGER,
is_read INTEGER, is_read INTEGER,
file TEXT
file TEXT,
message_expiry TEXT
); );
'''); ''');


+ 1
- 1
mobile/lib/utils/storage/messages.dart View File

@ -100,7 +100,7 @@ Future<void> sendMessage(Conversation conversation, {
body: jsonEncode(messagesToSend), body: jsonEncode(messagesToSend),
) )
.then((resp) { .then((resp) {
if (resp.statusCode != 200) {
if (resp.statusCode != 204) {
throw Exception('Unable to send message'); throw Exception('Unable to send message');
} }
}) })


+ 2
- 2
mobile/lib/views/authentication/login.dart View File

@ -87,8 +87,8 @@ class _LoginWidgetState extends State<LoginWidget> {
); );
final ButtonStyle buttonStyle = ElevatedButton.styleFrom( final ButtonStyle buttonStyle = ElevatedButton.styleFrom(
primary: Theme.of(context).colorScheme.surface,
onPrimary: Theme.of(context).colorScheme.onSurface,
backgroundColor: Theme.of(context).colorScheme.surface,
foregroundColor: Theme.of(context).colorScheme.onSurface,
minimumSize: const Size.fromHeight(50), minimumSize: const Size.fromHeight(50),
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
textStyle: TextStyle( textStyle: TextStyle(


+ 9
- 2
mobile/lib/views/main/conversation/detail.dart View File

@ -271,8 +271,14 @@ class _ConversationDetailState extends State<ConversationDetail> {
], ],
), ),
showFilePicker ?
AnimatedSwitcher(
duration: const Duration(milliseconds: 250),
transitionBuilder: (Widget child, Animation<double> animation) {
return SizeTransition(sizeFactor: animation, child: child);
},
child: showFilePicker ?
FilePicker( FilePicker(
key: const Key('filePicker'),
cameraHandle: (XFile image) {}, cameraHandle: (XFile image) {},
galleryHandleMultiple: (List<XFile> images) async { galleryHandleMultiple: (List<XFile> images) async {
for (var img in images) { for (var img in images) {
@ -284,7 +290,8 @@ class _ConversationDetailState extends State<ConversationDetail> {
}, },
fileHandle: () {}, fileHandle: () {},
) : ) :
const SizedBox.shrink(),
const SizedBox(height: 15),
),
], ],
), ),
), ),


+ 54
- 15
mobile/lib/views/main/conversation/settings.dart View File

@ -1,14 +1,18 @@
import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:Capsule/components/custom_title_bar.dart';
import 'package:Capsule/components/flash_message.dart';
import 'package:Capsule/exceptions/update_data_exception.dart';
import 'package:Capsule/models/friends.dart';
import 'package:Capsule/utils/encryption/crypto_utils.dart';
import 'package:Capsule/utils/storage/write_file.dart';
import 'package:Capsule/views/main/conversation/create_add_users.dart';
import 'package:Capsule/utils/storage/session_cookie.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import '/components/custom_title_bar.dart';
import '/components/flash_message.dart';
import '/components/select_message_ttl.dart';
import '/exceptions/update_data_exception.dart';
import '/models/friends.dart';
import '/utils/encryption/crypto_utils.dart';
import '/utils/storage/write_file.dart';
import '/views/main/conversation/create_add_users.dart';
import '/models/conversation_users.dart'; import '/models/conversation_users.dart';
import '/models/conversations.dart'; import '/models/conversations.dart';
import '/models/my_profile.dart'; import '/models/my_profile.dart';
@ -122,13 +126,7 @@ class _ConversationSettingsState extends State<ConversationSettings> {
widget.conversation.name = conversationName; widget.conversation.name = conversationName;
widget.conversation.icon = writtenFile; widget.conversation.icon = writtenFile;
final db = await getDatabaseConnection();
db.update(
'conversations',
widget.conversation.toMap(),
where: 'id = ?',
whereArgs: [widget.conversation.id],
);
await saveConversation();
await updateConversation(widget.conversation, updatedImage: updatedImage) await updateConversation(widget.conversation, updatedImage: updatedImage)
.catchError((error) { .catchError((error) {
@ -256,7 +254,38 @@ class _ConversationSettingsState extends State<ConversationSettings> {
) )
), ),
onPressed: () { onPressed: () {
print('Disappearing Messages');
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => SelectMessageTTL(
widgetTitle: 'Message Expiry',
currentSelected: widget.conversation.messageExpiryDefault,
backCallback: (String messageExpiry) async {
widget.conversation.messageExpiryDefault = messageExpiry;
http.post(
await MyProfile.getServerUrl(
'api/v1/auth/conversations/${widget.conversation.id}/message_expiry'
),
headers: {
'cookie': await getSessionCookie(),
},
body: jsonEncode({
'message_expiry': messageExpiry,
}),
).then((http.Response response) {
if (response.statusCode == 204) {
return;
}
showMessage(
'Could not change the default message expiry, please try again later.',
context,
);
});
saveConversation();
}
))
);
} }
), ),
TextButton.icon( TextButton.icon(
@ -331,5 +360,15 @@ return Theme.of(context).colorScheme.onBackground;
getUsers(); getUsers();
setState(() {}); setState(() {});
} }
saveConversation() async {
final db = await getDatabaseConnection();
db.update(
'conversations',
widget.conversation.toMap(),
where: 'id = ?',
whereArgs: [widget.conversation.id],
);
}
} }

+ 1
- 1
mobile/lib/views/main/profile/change_password.dart View File

@ -169,7 +169,7 @@ class ChangePassword extends StatelessWidget {
return; return;
} }
if (resp.statusCode != 200) {
if (resp.statusCode != 204) {
showMessage( showMessage(
'An unexpected error occured, please try again later.', 'An unexpected error occured, please try again later.',
context, context,


+ 11
- 5
mobile/lib/views/main/profile/profile.dart View File

@ -64,7 +64,6 @@ class _ProfileState extends State<Profile> {
backdropEnabled: true, backdropEnabled: true,
backdropOpacity: 0.2, backdropOpacity: 0.2,
minHeight: 0, minHeight: 0,
maxHeight: 450,
panel: Center( panel: Center(
child: _profileQrCode(), child: _profileQrCode(),
), ),
@ -73,7 +72,13 @@ class _ProfileState extends State<Profile> {
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
usernameHeading(), usernameHeading(),
fileSelector(),
AnimatedSwitcher(
duration: const Duration(milliseconds: 250),
transitionBuilder: (Widget child, Animation<double> animation) {
return SizeTransition(sizeFactor: animation, child: child);
},
child: fileSelector(),
),
SizedBox(height: showFileSelector ? 10 : 30), SizedBox(height: showFileSelector ? 10 : 30),
settings(), settings(),
const SizedBox(height: 30), const SizedBox(height: 30),
@ -126,7 +131,8 @@ class _ProfileState extends State<Profile> {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
return Padding(
return Padding(
key: const Key('fileSelector'),
padding: const EdgeInsets.only(top: 10), padding: const EdgeInsets.only(top: 10),
child: FilePicker( child: FilePicker(
cameraHandle: _setProfileImage, cameraHandle: _setProfileImage,
@ -168,7 +174,7 @@ class _ProfileState extends State<Profile> {
} }
showMessage( showMessage(
'Could not change your default message expiry, please try again later.',
'Could not add profile picture, please try again later.',
context, context,
); );
}); });
@ -255,7 +261,7 @@ class _ProfileState extends State<Profile> {
'message_expiry': messageExpiry, 'message_expiry': messageExpiry,
}), }),
).then((http.Response response) { ).then((http.Response response) {
if (response.statusCode == 200) {
if (response.statusCode == 204) {
return; return;
} }


+ 12
- 19
mobile/pubspec.lock View File

@ -14,7 +14,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.8.2"
version: "2.9.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -28,21 +28,14 @@ packages:
name: characters name: characters
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.2.1"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0"
version: "1.1.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
@ -84,7 +77,7 @@ packages:
name: fake_async name: fake_async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0"
version: "1.3.1"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
@ -218,21 +211,21 @@ packages:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.11"
version: "0.12.12"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.4"
version: "0.1.5"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0"
version: "1.8.0"
mime: mime:
dependency: "direct main" dependency: "direct main"
description: description:
@ -246,7 +239,7 @@ packages:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.1"
version: "1.8.2"
path_provider: path_provider:
dependency: "direct main" dependency: "direct main"
description: description:
@ -419,7 +412,7 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.2"
version: "1.9.0"
sqflite: sqflite:
dependency: "direct main" dependency: "direct main"
description: description:
@ -454,7 +447,7 @@ packages:
name: string_scanner name: string_scanner
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0"
version: "1.1.1"
synchronized: synchronized:
dependency: transitive dependency: transitive
description: description:
@ -468,14 +461,14 @@ packages:
name: term_glyph name: term_glyph
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0"
version: "1.2.1"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.9"
version: "0.4.12"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:


+ 1
- 1
mobile/pubspec.yaml View File

@ -18,7 +18,7 @@ dependencies:
http: ^0.13.4 http: ^0.13.4
shared_preferences: ^2.0.15 shared_preferences: ^2.0.15
sqflite: ^2.0.2 sqflite: ^2.0.2
path: 1.8.1
path: any
flutter_dotenv: ^5.0.2 flutter_dotenv: ^5.0.2
intl: ^0.17.0 intl: ^0.17.0
uuid: ^3.0.6 uuid: ^3.0.6


Loading…
Cancel
Save