diff --git a/src/main/java/com/github/polpetta/mezzotre/orm/model/Campaign.java b/src/main/java/com/github/polpetta/mezzotre/orm/model/Campaign.java index aab035e..eac63e2 100644 --- a/src/main/java/com/github/polpetta/mezzotre/orm/model/Campaign.java +++ b/src/main/java/com/github/polpetta/mezzotre/orm/model/Campaign.java @@ -18,14 +18,17 @@ public class Campaign extends Base { @NotNull private String name; - @Nullable @Null private String description; + @Length(4096) + @Nullable + @Null + private String description; @ManyToMany(fetch = FetchType.LAZY) private List users; - public Campaign(String id, String campaignName, @Nullable String description) { + public Campaign(String id, String name, @Nullable String description) { this.id = id; - this.name = campaignName; + this.name = name; this.description = description; } diff --git a/src/main/java/com/github/polpetta/mezzotre/telegram/command/CreateCampaign.java b/src/main/java/com/github/polpetta/mezzotre/telegram/command/CreateCampaign.java index e1be4c8..5aa2818 100644 --- a/src/main/java/com/github/polpetta/mezzotre/telegram/command/CreateCampaign.java +++ b/src/main/java/com/github/polpetta/mezzotre/telegram/command/CreateCampaign.java @@ -53,6 +53,11 @@ public class CreateCampaign implements Processor { return Set.of(TRIGGERING_KEYWORD, "/newCampaign"); } + @Override + public String getLocaleDescriptionKeyword() { + return "createCampaign.cmdDescription"; + } + @Override public CompletableFuture>> process(TgChat chat, Update update) { // There are multiple steps, we have to route the incoming campaign creation to the right one diff --git a/src/main/resources/db/migration/V1_0_0__Create_initial_db.sql b/src/main/resources/db/migration/V1_0_0__Create_initial_db.sql index 97b5e0a..571af5d 100644 --- a/src/main/resources/db/migration/V1_0_0__Create_initial_db.sql +++ b/src/main/resources/db/migration/V1_0_0__Create_initial_db.sql @@ -8,6 +8,21 @@ create table callback_query_context ( constraint pk_callback_query_context primary key (id) ); +create table campaign ( + id varchar(64) not null, + name varchar(256) not null, + description varchar(4096), + entry_created timestamptz not null, + entry_modified timestamptz not null, + constraint pk_campaign primary key (id) +); + +create table campaign_registered_user ( + campaign_id varchar(64) not null, + registered_user_id varchar(64) not null, + constraint pk_campaign_registered_user primary key (campaign_id,registered_user_id) +); + create table telegram_chat ( id bigint generated by default as identity not null, chat_context jsonb not null default '{}'::jsonb not null, @@ -29,5 +44,23 @@ create table registered_user ( constraint pk_registered_user primary key (id) ); +create table registered_user_campaign ( + registered_user_id varchar(64) not null, + campaign_id varchar(64) not null, + constraint pk_registered_user_campaign primary key (registered_user_id,campaign_id) +); + -- foreign keys and indices +create index ix_campaign_registered_user_campaign on campaign_registered_user (campaign_id); +alter table campaign_registered_user add constraint fk_campaign_registered_user_campaign foreign key (campaign_id) references campaign (id) on delete restrict on update restrict; + +create index ix_campaign_registered_user_registered_user on campaign_registered_user (registered_user_id); +alter table campaign_registered_user add constraint fk_campaign_registered_user_registered_user foreign key (registered_user_id) references registered_user (id) on delete restrict on update restrict; + alter table registered_user add constraint fk_registered_user_telegram_id foreign key (telegram_id) references telegram_chat (id) on delete cascade on update restrict; + +create index ix_registered_user_campaign_registered_user on registered_user_campaign (registered_user_id); +alter table registered_user_campaign add constraint fk_registered_user_campaign_registered_user foreign key (registered_user_id) references registered_user (id) on delete restrict on update restrict; + +create index ix_registered_user_campaign_campaign on registered_user_campaign (campaign_id); +alter table registered_user_campaign add constraint fk_registered_user_campaign_campaign foreign key (campaign_id) references campaign (id) on delete restrict on update restrict; diff --git a/src/main/resources/i18n/message.properties b/src/main/resources/i18n/message.properties index 607c273..1f4410b 100644 --- a/src/main/resources/i18n/message.properties +++ b/src/main/resources/i18n/message.properties @@ -29,3 +29,4 @@ createCampaign.creationDone=All done! I have successfully added your campaign to createCampaign.finalCreationAction=*Finishes to write down on the scroll the last details* createCampaign.lookToPileAction=*Moves the scroll into a pile of other, disorganized, scrolls* createCampaign.shareCampaign=Now, if you want, you can share this campaign to other players so that they can join! To do this, just click on the button below and then select the user or the group you want to share this campaign with! They will be able to add their characters and see the other characters in this campaign +createCampaign.cmdDescription=Create a new DnD campaign diff --git a/src/main/resources/i18n/message_en_US.properties b/src/main/resources/i18n/message_en_US.properties index 607c273..1f4410b 100644 --- a/src/main/resources/i18n/message_en_US.properties +++ b/src/main/resources/i18n/message_en_US.properties @@ -29,3 +29,4 @@ createCampaign.creationDone=All done! I have successfully added your campaign to createCampaign.finalCreationAction=*Finishes to write down on the scroll the last details* createCampaign.lookToPileAction=*Moves the scroll into a pile of other, disorganized, scrolls* createCampaign.shareCampaign=Now, if you want, you can share this campaign to other players so that they can join! To do this, just click on the button below and then select the user or the group you want to share this campaign with! They will be able to add their characters and see the other characters in this campaign +createCampaign.cmdDescription=Create a new DnD campaign diff --git a/src/main/resources/i18n/message_it.properties b/src/main/resources/i18n/message_it.properties index 6b49a81..0a23b4e 100644 --- a/src/main/resources/i18n/message_it.properties +++ b/src/main/resources/i18n/message_it.properties @@ -21,3 +21,4 @@ help.buttonsToo=Puoi fare le stesse operazioni che faresti con i comandi elencat help.cmdDescription=Stampa il messaggio d''aiuto notfound.description=Mmm non sono in grado di trovare il comando {0}, sei sicuro di averlo scritto correttamente? notfound.howToHelp=Lascia che ti mostri cosa posso fare, scrivi /help nella chat! +createCampaign.cmdDescription=Crea una nuova campagna di DnD diff --git a/src/main/resources/i18n/message_it_IT.properties b/src/main/resources/i18n/message_it_IT.properties index 6b49a81..0a23b4e 100644 --- a/src/main/resources/i18n/message_it_IT.properties +++ b/src/main/resources/i18n/message_it_IT.properties @@ -21,3 +21,4 @@ help.buttonsToo=Puoi fare le stesse operazioni che faresti con i comandi elencat help.cmdDescription=Stampa il messaggio d''aiuto notfound.description=Mmm non sono in grado di trovare il comando {0}, sei sicuro di averlo scritto correttamente? notfound.howToHelp=Lascia che ti mostri cosa posso fare, scrivi /help nella chat! +createCampaign.cmdDescription=Crea una nuova campagna di DnD