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

Fix DB Compatibility & small fixes #33

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -56,7 +56,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -69,4 +69,4 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
14 changes: 7 additions & 7 deletions .github/workflows/docker-image-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
packages: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Docker metadata
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: |
aunefyren/poenskelisten
Expand All @@ -25,17 +25,17 @@ jobs:
flavor: |
latest=false
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand All @@ -45,7 +45,7 @@ jobs:
- name: Replace version variable
run: sed -i 's/{{RELEASE_TAG}}/beta-${{ env.GITHUB_SHA_SHORT }}/g' config/config.go # Replace release variable with the name of this release
- name: Build and push
uses: docker/build-push-action@v5.1.0
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
file: ./Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
packages: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Docker metadata
id: meta
uses: docker/metadata-action@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.19', '1.20', '1.21.x' ]
go-version: [ '1.21', '1.22.x' ]

steps:
- uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
# You can test your matrix by printing the current Go version
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
- goarch: arm64, arm
goos: windows
steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1.40
- uses: actions/checkout@v4
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GIT_HUB_TOKEN }}
goos: ${{ matrix.goos }}
Expand Down
1 change: 0 additions & 1 deletion controllers/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,6 @@ func APIUpdateGroup(context *gin.Context) {
}

func ConvertGroupToGroupObject(group models.Group) (groupObject models.GroupUser, err error) {
err = nil
groupObject = models.GroupUser{}

// Add owner information to group
Expand Down
11 changes: 5 additions & 6 deletions controllers/news.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"aunefyren/poenskelisten/utilities"
"log"
"net/http"
"strconv"
"strings"

"github.com/gin-gonic/gin"
Expand All @@ -33,7 +32,7 @@ func GetNewsPost(context *gin.Context) {

var newsID = context.Param("news_id")

newsIDInt, err := strconv.Atoi(newsID)
newsIDUUID, err := uuid.Parse(newsID)
if err != nil {
log.Println("Failed to parse request. Error: " + err.Error())
context.JSON(http.StatusBadRequest, gin.H{"error": "Failed parse request."})
Expand All @@ -42,7 +41,7 @@ func GetNewsPost(context *gin.Context) {
}

// Get the newspost by id
newsPost, err := database.GetNewsPostByNewsID(newsIDInt)
newsPost, err := database.GetNewsPostByNewsID(newsIDUUID)
if err != nil {
// If there is an error getting the news, return an internal server error
log.Println("Failed to get news post. Error: " + err.Error())
Expand Down Expand Up @@ -150,7 +149,7 @@ func DeleteNewsPost(context *gin.Context) {
newsID := context.Param("news_id")

// Parse news ID as integer
newsIDInt, err := strconv.Atoi(newsID)
newsIDUUID, err := uuid.Parse(newsID)
if err != nil {
log.Println("Failed to parse request. Error: " + err.Error())
context.JSON(http.StatusBadRequest, gin.H{"error": "Failed to parse request."})
Expand All @@ -159,7 +158,7 @@ func DeleteNewsPost(context *gin.Context) {
}

// Verify that news post exists
_, err = database.GetNewsPostByNewsID(newsIDInt)
_, err = database.GetNewsPostByNewsID(newsIDUUID)
if err != nil {
// If there is an error getting the news, return an internal server error
log.Println("Failed to get news post. Error: " + err.Error())
Expand All @@ -169,7 +168,7 @@ func DeleteNewsPost(context *gin.Context) {
}

// Set the news post to disabled in the database
err = database.DeleteNewsPost(newsIDInt)
err = database.DeleteNewsPost(newsIDUUID)
if err != nil {
log.Println("Failed to delete news post. Error: " + err.Error())
context.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to delete news post."})
Expand Down
10 changes: 4 additions & 6 deletions controllers/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func RegisterUser(context *gin.Context) {
}

func GetUser(context *gin.Context) {

var userObject models.User
// Create user request
var user = context.Param("user_id")

Expand Down Expand Up @@ -234,8 +234,7 @@ func GetUser(context *gin.Context) {
return
}

userObject := models.User{}
if userID == user_id_int || (requestingUserObject.Admin != nil && *requestingUserObject.Admin == true) {
if userID == user_id_int || (requestingUserObject.Admin != nil && *requestingUserObject.Admin) {
userObject, err = database.GetAllUserInformationAnyState(user_id_int)
if err != nil {
log.Println("Failed to get user. Error: " + err.Error())
Expand All @@ -258,6 +257,7 @@ func GetUser(context *gin.Context) {
}

func GetUsers(context *gin.Context) {
var users []models.User

// Get user ID
userID, err := middlewares.GetAuthUsername(context.GetHeader("Authorization"))
Expand All @@ -276,10 +276,8 @@ func GetUsers(context *gin.Context) {
return
}

users := []models.User{}

includeDisabled, okay := context.GetQuery("includeDisabled")
if okay && strings.ToLower(includeDisabled) == "true" && requestingUserObject.Admin != nil && *requestingUserObject.Admin == true {
if okay && strings.ToLower(includeDisabled) == "true" && requestingUserObject.Admin != nil && *requestingUserObject.Admin {
users, err = database.GetAllUsers()
if err != nil {
log.Println("Failed to get all users. Error: " + err.Error())
Expand Down
15 changes: 2 additions & 13 deletions controllers/wishlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func RegisterWishlist(context *gin.Context) {
var wishlists_with_users []models.WishlistUser

// If a group was referenced, create the wishlist membership
if group_membership == true {
if group_membership {
var wishlistmembershipdb models.WishlistMembership
wishlistmembershipdb.GroupID = group_id
wishlistmembershipdb.WishlistID = wishlistdb.ID
Expand Down Expand Up @@ -295,9 +295,6 @@ func DeleteWishlist(context *gin.Context) {
}

func GetWishlistObjectsFromGroup(group_id uuid.UUID, RequestUserID uuid.UUID) (wishlistObjects []models.WishlistUser, err error) {
err = nil
wishlistObjects = []models.WishlistUser{}

wishlists, err := database.GetWishlistsFromGroup(group_id)
if err != nil {
return []models.WishlistUser{}, err
Expand Down Expand Up @@ -379,9 +376,6 @@ func GetWishlist(context *gin.Context) {
}

func GetWishlistObject(WishlistID uuid.UUID, RequestUserID uuid.UUID) (wishlistObject models.WishlistUser, err error) {
err = nil
wishlistObject = models.WishlistUser{}

wishlist, err := database.GetWishlist(WishlistID)
if err != nil {
log.Println("Failed to get wishlist '" + WishlistID.String() + "' from DB. Returning. Error: " + err.Error())
Expand Down Expand Up @@ -460,7 +454,6 @@ func GetWishlists(context *gin.Context) {
}

func GetWishlistObjects(UserID uuid.UUID) (wishlistObjects []models.WishlistUser, err error) {
err = nil
wishlistObjects = []models.WishlistUser{}

wishlists, err := database.GetOwnedWishlists(UserID)
Expand All @@ -475,9 +468,7 @@ func GetWishlistObjects(UserID uuid.UUID) (wishlistObjects []models.WishlistUser
return wishlistObjects, errors.New("Failed to get collaboration wishlists for user '" + UserID.String() + "'.")
}

for _, wishlistThroughCollab := range wishlistsThroughCollab {
wishlists = append(wishlists, wishlistThroughCollab)
}
wishlists = append(wishlists, wishlistsThroughCollab...)

wishlistObjects, err = ConvertWishlistsToWishlistObjects(wishlists, &UserID)
if err != nil {
Expand Down Expand Up @@ -895,7 +886,6 @@ func APIUpdateWishlist(context *gin.Context) {
}

func ConvertWishlistCollaberatorToWishlistCollaberatorObject(wishlistCollab models.WishlistCollaborator) (wishlistCollabObject models.WishlistCollaboratorObject, err error) {
err = nil
wishlistCollabObject = models.WishlistCollaboratorObject{}

userObject, err := database.GetUserInformation(wishlistCollab.UserID)
Expand Down Expand Up @@ -935,7 +925,6 @@ func ConvertWishlistCollaberatorsToWishlistCollaberatorObjects(wishlistCollabs [
}

func ConvertWishlistToWishlistObject(wishlist models.Wishlist, RequestUserID *uuid.UUID) (wishlistObject models.WishlistUser, err error) {
err = nil
wishlistObject = models.WishlistUser{}

groups, err := database.GetGroupMembersFromWishlist(wishlist.ID)
Expand Down
Loading