Skip to content

Commit

Permalink
Resolve backward compatibility issues (mattermost#29566)
Browse files Browse the repository at this point in the history
Co-authored-by: Mattermost Build <[email protected]>
  • Loading branch information
Honsei901 and mattermost-build authored Dec 13, 2024
1 parent 9b67fb7 commit 01415be
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions server/channels/store/sqlstore/outgoing_oauth_connection_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@ import (

type SqlOutgoingOAuthConnectionStore struct {
*SqlStore

tableSelectQuery sq.SelectBuilder
}

func newSqlOutgoingOAuthConnectionStore(sqlStore *SqlStore) store.OutgoingOAuthConnectionStore {
return &SqlOutgoingOAuthConnectionStore{sqlStore}
s := SqlOutgoingOAuthConnectionStore{
SqlStore: sqlStore,
}

s.tableSelectQuery = s.getQueryBuilder().
Select("Id", "CreatorId", "CreateAt", "UpdateAt", "Name", "ClientId", "ClientSecret", "CredentialsUsername", "CredentialsPassword", "OAuthTokenURL", "GrantType", "Audiences").
From("OutgoingOAuthConnections")

return &s
}

func (s *SqlOutgoingOAuthConnectionStore) SaveConnection(c request.CTX, conn *model.OutgoingOAuthConnection) (*model.OutgoingOAuthConnection, error) {
Expand Down Expand Up @@ -86,7 +96,9 @@ func (s *SqlOutgoingOAuthConnectionStore) UpdateConnection(c request.CTX, conn *

func (s *SqlOutgoingOAuthConnectionStore) GetConnection(c request.CTX, id string) (*model.OutgoingOAuthConnection, error) {
conn := &model.OutgoingOAuthConnection{}
if err := s.GetReplica().Get(conn, `SELECT * FROM OutgoingOAuthConnections WHERE Id=?`, id); err != nil {
query := s.tableSelectQuery.Where(sq.Eq{"Id": id})

if err := s.GetReplica().GetBuilder(conn, query); err != nil {
if err == sql.ErrNoRows {
return nil, store.NewErrNotFound("OutgoingOAuthConnection", id)
}
Expand All @@ -99,11 +111,7 @@ func (s *SqlOutgoingOAuthConnectionStore) GetConnections(c request.CTX, filters
filters.SetDefaults()

conns := []*model.OutgoingOAuthConnection{}
query := s.getQueryBuilder().
Select("*").
From("OutgoingOAuthConnections").
OrderBy("Id").
Limit(uint64(filters.Limit))
query := s.tableSelectQuery.OrderBy("Id").Limit(uint64(filters.Limit))

if filters.OffsetId != "" {
query = query.Where("Id > ?", filters.OffsetId)
Expand Down

0 comments on commit 01415be

Please sign in to comment.