Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images #168

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,27 @@ const (
DefaultRange = 50000 // default distance to include schools in, in meters
HottestPostNotificationsLowerBound = "00:00" // the lower bound of the hottest post notifications cron job - 24h time
HottestPostNotificationsUpperBound = "23:59" // the upper bound of the hottest post notifications cron job - 24h time
TitleMaxLength = 100 // max length of a post title
BodyMaxLength = 1000 // max length of a post content/body
)

// ----- DEPLOYMENT CONSTANTS

const (
iOSBundleId = "com.confesi.app" // iOS bundle id // TODO: change this
AndroidPackageName = "com.confesi.app" // Android package name // TODO: change this
FirebaseProjectID = "confesi-server-dev" // Firebase project id // TODO: change this
iOSBundleId = "com.confesi.app"
AndroidPackageName = "com.confesi.app"
FirebaseProjectID = "confesi-server-dev" // Firebase project id
Development = true // development mode
)

// ---- AWS CONSTANTS

const (
AwsUserUploadsBucket string = "confesi-uploads"
AwsRekognitionConfidenceThreshold float64 = 80
AwsUserUploadsBucketBaseUrl string = "https://confesi-uploads.s3.us-east-2.amazonaws.com/"
)

// ----- ALT CONSTANTS

// -> pther constants are defined directly in the request struct validation tags, here: ~/lib/validation/models.go
44 changes: 44 additions & 0 deletions db/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql/driver"
"encoding/json"
"fmt"
"strings"

"time"

Expand All @@ -13,6 +14,48 @@ import (
"gorm.io/datatypes"
)

type PgTxtArr []string

func (a *PgTxtArr) Scan(src interface{}) error {
var str string
switch v := src.(type) {
case []byte:
str = string(v)
case string:
str = v
default:
return fmt.Errorf("unable to scan PgTxtArr: unexpected type: %T", src)
}

// Trimming the surrounding curly braces of PostgreSQL arrays
str = strings.Trim(str, "{}")

// If the trimmed string is empty, it means the array was empty.
if str == "" {
*a = []string{}
return nil
}

// Splitting by comma, but be careful about commas inside the URLs
pieces := strings.Split(str, ",")

// Check and handle quoted strings
var cleanPieces []string
for _, piece := range pieces {
if strings.HasPrefix(piece, `"`) && strings.HasSuffix(piece, `"`) {
piece = strings.Trim(piece, `"`)
}
cleanPieces = append(cleanPieces, piece)
}

*a = cleanPieces
return nil
}

func (a PgTxtArr) Value() (driver.Value, error) {
return "{" + strings.Join(a, ",") + "}", nil
}

type EncryptedID struct {
Val uint
}
Expand Down Expand Up @@ -179,6 +222,7 @@ type Post struct {
CategoryID EncryptedID `gorm:"column:category_id" json:"-"`
Category PostCategory `gorm:"foreignKey:CategoryID" json:"category"`
CommentCount uint `gorm:"column:comment_count" json:"comment_count"`
ImgUrls PgTxtArr `gorm:"column:img_urls" json:"img_urls"`
}

// ! Very important that SOME FIELDS ARE NOT EVER SERIALIZED TO PROTECT SENSATIVE DATA (json:"-")
Expand Down
30 changes: 15 additions & 15 deletions features/admin/requests.http

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions features/auth/requests.http
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Content-Type: application/json
PATCH http://127.0.0.1:8080/api/v1/auth/update-email
Content-Type: application/json
X-AppCheck-Token: kXfeSRgYTnoUztu6MO8FndqiRayoBaJqyDKQmoqvX3V9sZVlep/cm7cP!mgd-B9H
Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjYzODBlZjEyZjk1ZjkxNmNhZDdhNGNlMzg4ZDJjMmMzYzIzMDJmZGUiLCJ0eXAiOiJKV1QifQ.eyJyb2xlcyI6W10sInN5bmMiOnRydWUsImlzcyI6Imh0dHBzOi8vc2VjdXJldG9rZW4uZ29vZ2xlLmNvbS9jb25mZXNpLXNlcnZ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QiOiJyQm5LcERKS3FpZ05kNTNTY1JBQktIbXR3VGoxIiwic3ViIjoickJuS3BESktxaWdOZDUzU2NSQUJLSG10d1RqMSIsImlhdCI6MTY5MjYwNDU2NSwiZXhwIjoxNjkyNjA4MTY1LCJlbWFpbCI6Im1hdHRoZXcucmwudHJlbnRAZ21haWwuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImZpcmViYXNlIjp7ImlkZW50aXRpZXMiOnsiZW1haWwiOlsibWF0dGhldy5ybC50cmVudEBnbWFpbC5jb20iXX0sInNpZ25faW5fcHJvdmlkZXIiOiJwYXNzd29yZCJ9fQ.TFcUPPhBWFFcrPaDFXkUn_0fToiOb_vkCDvP_OjiQK0PsjSUtcAXMpxgXSB3j5BjiqDXdUBPfKqIwOZKb0PB_VO1AIpLZqcN81F1sXXSulgpPzPnNJCYvtgFeG4rJV6sY0Ie79oqvQnWCbRX1N-Ahi8SPQphea698XrlinUPe6uASvg_XxhbBGrZ6HNsqX7_3m4jVO5xmk6QqC25n6TxO88H-CEpStDHPnfZHQjjiDiq59RZbKvRMym7LcD1237XMOSnrtwKgWsqQPU_WeSmjsNONUxvRXS7FB0qeh4q6MGqUT2BbRhen181llfa-aLKbaDvROSpuvBcvQgh1szbbA

{
"email": "[email protected]"
Expand All @@ -25,13 +25,13 @@ Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjYzODBlZjEyZjk1ZjkxNmNhZDdhNG

POST http://127.0.0.1:8080/api/v1/auth/resend-verification-email
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjYzODBlZjEyZjk1ZjkxNmNhZDdhNGNlMzg4ZDJjMmMzYzIzMDJmZGUiLCJ0eXAiOiJKV1QifQ.eyJyb2xlcyI6W10sInN5bmMiOnRydWUsImlzcyI6Imh0dHBzOi8vc2VjdXJldG9rZW4uZ29vZ2xlLmNvbS9jb25mZXNpLXNlcnZlci1kZXYiLCJhdWQiOiJjb25mZXNpLXNlc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bXR3VGoxIiwic3ViIjoickJuS3BESktxaWdOZDUzU2NSQUJLSG10d1RqMSIsImlhdCI6MTY5MjYwNDU2NSwiZXhwIjoxNjkyNjA4MTY1LCJlbWFpbCI6Im1hdHRoZXcucmwudHJlbnRAZ21haWwuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImZpcmViYXNlIjp7ImlkZW50aXRpZXMiOnsiZW1haWwiOlsibWF0dGhldy5ybC50cmVudEBnbWFpbC5jb20iXX0sInNpZ25faW5fcHJvdmlkZXIiOiJwYXNzd29yZCJ9fQ.TFcUPPhBWFFcrPaDFXkUn_0fToiOb_vkCDvP_OjiQK0PsjSUtcAXMpxgXSB3j5BjiqDXdUBPfKqIwOZKb0PB_VO1AIpLZqcN81F1sXXSulgpPzPnNJCYvtgFeG4rJV6sY0Ie79oqvQnWCbRX1N-Ahi8SPQphea698XrlinUPe6uASvg_XxhbBGrZ6HNsqX7_3m4jVO5xmk6QqC25n6TxO88H-CEpStDHPnfZHQjjiDiq59RZbKvRMym7LcD1237XMOSnrtwKgWsqQPU_WeSmjsNONUxvRXS7FB0qeh4q6MGqUT2BbRhen181llfa-aLKbaDvROSpuvBcvQgh1szbbA

### Send password reset email

POST http://127.0.0.1:8080/api/v1/auth/send-password-reset-email
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjYzODBlZjEyZjk1ZjkxNmNhZDdhNGNlMzg4ZDJjMmMzYzIzMDJmZGUiLCJ0eXAiOiJKV1QifQ.eyJyb2xlcyI6W10sInN5bmMiOnRydWUsImlzcyI6Imh0dHBzOi8vc2VjdXJldG9rZW4uZ29vZ2xlLmNvbS9jb25mZXNpLXNlcnZlci1kZXYiLCJhdWQiOiJjb25mZXNpLXNlcnZlci1kZXYiLCJhdXRoX3RpbWUiOjE2OTIzOTQ5NDksInVzZXJfaWQiOiJyQm5LcERKS3FpZ05kNTNTY1JBQktIbXR3VGoxIiwic3ViIjoickJuS3BESktxaWdOZDUzU2NS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