mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-22 09:35:08 -07:00
[Server] Add deck share links and public deck visibility
This commit is contained in:
parent
51365960fe
commit
8f674aab78
24 changed files with 899 additions and 19 deletions
|
|
@ -13,10 +13,22 @@
|
|||
#include <server.h>
|
||||
#include <server_database_interface.h>
|
||||
|
||||
#define DATABASE_SCHEMA_VERSION 36
|
||||
#define DATABASE_SCHEMA_VERSION 37
|
||||
|
||||
class Servatrice;
|
||||
|
||||
/** @brief Metadata of a single deck inside a temporary deck share bundle. */
|
||||
struct DeckShareItemRecord
|
||||
{
|
||||
int id = -1; ///< Database id, used for downloads.
|
||||
QString name; ///< Deck name.
|
||||
QStringList tags; ///< Deck tags.
|
||||
QString bannerCard; ///< Banner card name (deck image).
|
||||
QString gameFormat; ///< Game format the deck was built for.
|
||||
QString colorIdentity; ///< Color identity, e.g. "WUBRG".
|
||||
QString content; ///< Deck content (native format); empty in list queries.
|
||||
};
|
||||
|
||||
class Servatrice_DatabaseInterface : public Server_DatabaseInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -80,6 +92,25 @@ public:
|
|||
const QList<GameReplay *> &replayList) override;
|
||||
DeckList *getDeckFromDatabase(int deckId, int userId) override;
|
||||
|
||||
/** @brief Creates a new temporary deck share bundle. Returns false on failure. */
|
||||
bool createDeckShare(const QString &token,
|
||||
const QString &name,
|
||||
int userId,
|
||||
const QList<DeckShareItemRecord> &items,
|
||||
int expiryDays);
|
||||
/**
|
||||
* @brief Looks up a valid (non-expired) share bundle by token.
|
||||
* @return false if the token is unknown or expired.
|
||||
*/
|
||||
bool getDeckShareList(const QString &token, QString &name, qint64 &expiresAt, QList<DeckShareItemRecord> &items);
|
||||
/**
|
||||
* @brief Fetches the content of one item of a valid share bundle.
|
||||
* @return false if the token is unknown/expired or the item does not belong to the bundle.
|
||||
*/
|
||||
bool getDeckShareItem(const QString &token, int itemId, QString &content);
|
||||
/** @brief Deletes all expired share bundles (cascades to their items). */
|
||||
void cleanupExpiredDeckShares();
|
||||
|
||||
int getNextGameId() override;
|
||||
int getNextReplayId() override;
|
||||
int getActiveUserCount(QString connectionType = QString()) override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue