From 17dbc379641f9c54772df09ab10a4979ad9e968d Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Tue, 19 Nov 2024 13:41:52 +0530 Subject: [PATCH] chore_: Remove switcher cards (#6107) --- .../sql/1732000008_witcher_card.up.sql | 1 + protocol/messenger_switcher_cards.go | 26 ---------- protocol/persistence.go | 52 ------------------- protocol/requests/upsert_switcher_card.go | 20 ------- protocol/switcher_card.go | 8 --- services/ext/api.go | 23 -------- 6 files changed, 1 insertion(+), 129 deletions(-) create mode 100644 appdatabase/migrations/sql/1732000008_witcher_card.up.sql delete mode 100644 protocol/messenger_switcher_cards.go delete mode 100644 protocol/requests/upsert_switcher_card.go delete mode 100644 protocol/switcher_card.go diff --git a/appdatabase/migrations/sql/1732000008_witcher_card.up.sql b/appdatabase/migrations/sql/1732000008_witcher_card.up.sql new file mode 100644 index 000000000..a72d0b3d0 --- /dev/null +++ b/appdatabase/migrations/sql/1732000008_witcher_card.up.sql @@ -0,0 +1 @@ +DROP TABLE switcher_cards; diff --git a/protocol/messenger_switcher_cards.go b/protocol/messenger_switcher_cards.go deleted file mode 100644 index f140683fe..000000000 --- a/protocol/messenger_switcher_cards.go +++ /dev/null @@ -1,26 +0,0 @@ -package protocol - -import "github.com/status-im/status-go/protocol/requests" - -func (m *Messenger) UpsertSwitcherCard(request *requests.UpsertSwitcherCard) error { - if err := request.Validate(); err != nil { - return err - } - - switcherCard := SwitcherCard{ - CardID: request.CardID, - Type: request.Type, - Clock: request.Clock, - ScreenID: request.ScreenID, - } - - return m.persistence.UpsertSwitcherCard(switcherCard) -} - -func (m *Messenger) DeleteSwitcherCard(cardID string) error { - return m.persistence.DeleteSwitcherCard(cardID) -} - -func (m *Messenger) SwitcherCards() ([]SwitcherCard, error) { - return m.persistence.SwitcherCards() -} diff --git a/protocol/persistence.go b/protocol/persistence.go index 49543c9b4..9724c47b3 100644 --- a/protocol/persistence.go +++ b/protocol/persistence.go @@ -1189,58 +1189,6 @@ func (db sqlitePersistence) StatusUpdates() (statusUpdates []UserStatus, err err return } -func (db sqlitePersistence) DeleteSwitcherCard(cardID string) error { - _, err := db.db.Exec("DELETE from switcher_cards WHERE card_id = ?", cardID) - return err -} - -func (db sqlitePersistence) UpsertSwitcherCard(switcherCard SwitcherCard) error { - _, err := db.db.Exec(`INSERT INTO switcher_cards( - card_id, - type, - clock, - screen_id) - VALUES (?, ?, ?, ?)`, - switcherCard.CardID, - switcherCard.Type, - switcherCard.Clock, - switcherCard.ScreenID, - ) - - return err -} - -func (db sqlitePersistence) SwitcherCards() (switcherCards []SwitcherCard, err error) { - rows, err := db.db.Query(` - SELECT - card_id, - type, - clock, - screen_id - FROM switcher_cards - `) - if err != nil { - return - } - defer rows.Close() - - for rows.Next() { - var switcherCard SwitcherCard - err = rows.Scan( - &switcherCard.CardID, - &switcherCard.Type, - &switcherCard.Clock, - &switcherCard.ScreenID, - ) - if err != nil { - return - } - switcherCards = append(switcherCards, switcherCard) - } - - return -} - func (db sqlitePersistence) NextHigherClockValueOfAutomaticStatusUpdates(clock uint64) (uint64, error) { var nextClock uint64 diff --git a/protocol/requests/upsert_switcher_card.go b/protocol/requests/upsert_switcher_card.go deleted file mode 100644 index 0490927b0..000000000 --- a/protocol/requests/upsert_switcher_card.go +++ /dev/null @@ -1,20 +0,0 @@ -package requests - -import "errors" - -var ErrUpsertSwitcherCardInvalidCardID = errors.New("upsert-switcher-card: invalid card id") - -type UpsertSwitcherCard struct { - CardID string `json:"cardId,omitempty"` - Type int `json:"type"` - Clock uint64 `json:"clock"` - ScreenID string `json:"screenId"` -} - -func (a *UpsertSwitcherCard) Validate() error { - if len(a.CardID) == 0 { - return ErrUpsertSwitcherCardInvalidCardID - } - - return nil -} diff --git a/protocol/switcher_card.go b/protocol/switcher_card.go deleted file mode 100644 index 029c0621f..000000000 --- a/protocol/switcher_card.go +++ /dev/null @@ -1,8 +0,0 @@ -package protocol - -type SwitcherCard struct { - CardID string `json:"cardId,omitempty"` - Type int `json:"type"` - Clock uint64 `json:"clock"` - ScreenID string `json:"screenId"` -} diff --git a/services/ext/api.go b/services/ext/api.go index d82e77a53..1ce6c06f7 100644 --- a/services/ext/api.go +++ b/services/ext/api.go @@ -730,10 +730,6 @@ type ApplicationStatusUpdatesResponse struct { StatusUpdates []protocol.UserStatus `json:"statusUpdates"` } -type ApplicationSwitcherCardsResponse struct { - SwitcherCards []protocol.SwitcherCard `json:"switcherCards"` -} - func (api *PublicAPI) ChatMessages(chatID, cursor string, limit int) (*ApplicationMessagesResponse, error) { messages, cursor, err := api.service.messenger.MessageByChatID(chatID, cursor, limit) if err != nil { @@ -799,25 +795,6 @@ func (api *PublicAPI) StatusUpdates() (*ApplicationStatusUpdatesResponse, error) }, nil } -func (api *PublicAPI) UpsertSwitcherCard(request *requests.UpsertSwitcherCard) error { - return api.service.messenger.UpsertSwitcherCard(request) -} - -func (api *PublicAPI) DeleteSwitcherCard(id string) error { - return api.service.messenger.DeleteSwitcherCard(id) -} - -func (api *PublicAPI) SwitcherCards() (*ApplicationSwitcherCardsResponse, error) { - switcherCards, err := api.service.messenger.SwitcherCards() - if err != nil { - return nil, err - } - - return &ApplicationSwitcherCardsResponse{ - SwitcherCards: switcherCards, - }, nil -} - func (api *PublicAPI) StartMessenger() (*protocol.MessengerResponse, error) { return api.service.StartMessenger() }