Skip to content

Commit

Permalink
Refactor storage.go to add GetFilePathForRoom method
Browse files Browse the repository at this point in the history
  • Loading branch information
abdealijaroli committed Sep 29, 2024
1 parent e569dac commit 4dad7c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions store/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ func (s *PostgresStore) CreateShortURLTable() error {
return err
}

func (s *PostgresStore) GetFilePathForRoom(roomID string) (string, error) {
var filePath string
query := `SELECT original_url FROM accounts WHERE short_url = $1`
err := s.db.QueryRow(query, roomID).Scan(&filePath)
if err != nil {
return "", err
}
return filePath, nil
}

func (s *PostgresStore) AddShortURLToDB(originalURL string, shortURL string, isFileTransfer bool) error {
query := `INSERT INTO short_urls (original_url, short_url, is_file_transfer, created_at)
VALUES ($1, $2, $3, $4)
Expand Down

0 comments on commit 4dad7c1

Please sign in to comment.