feat: Add webhook profile picture support
- Added `webhookBotProfilePicture` field to `TeamDiscordIntegrationSchema`. - Updated `DiscordIntegrationForm.vue` to include profile picture input. - Created migration to add `webhook_bot_profile_picture` column. - Updated `Team` model to handle new profile picture field. - Modified `TeamDiscordIntegration` and `TeamDiscordIntegrationSchema` to include the new profile picture attribute.master
parent
ebbd969afd
commit
3d5d9574e3
|
@ -4,6 +4,7 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
export type TeamDiscordIntegrationSchema = {
|
export type TeamDiscordIntegrationSchema = {
|
||||||
webhookBotName: string;
|
webhookBotName: string;
|
||||||
|
webhookBotProfilePicture: (string | null);
|
||||||
webhookUrl: string;
|
webhookUrl: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ function enableIntegration() {
|
||||||
model.value = {
|
model.value = {
|
||||||
webhookUrl: "",
|
webhookUrl: "",
|
||||||
webhookBotName: "",
|
webhookBotName: "",
|
||||||
|
webhookBotProfilePicture: null,
|
||||||
};
|
};
|
||||||
saveIntegration();
|
saveIntegration();
|
||||||
}
|
}
|
||||||
|
@ -38,6 +39,10 @@ function disableIntegration() {
|
||||||
<h3>Webhook Bot Name</h3>
|
<h3>Webhook Bot Name</h3>
|
||||||
<input v-model="model.webhookBotName">
|
<input v-model="model.webhookBotName">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group margin">
|
||||||
|
<h3>Webhook Bot Profile Picture URL (optional)</h3>
|
||||||
|
<input v-model="model.webhookBotProfilePicture">
|
||||||
|
</div>
|
||||||
<div class="form-group margin">
|
<div class="form-group margin">
|
||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
<button class="destructive-on-hover" @click="disableIntegration">
|
<button class="destructive-on-hover" @click="disableIntegration">
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
"""Add webhook profile picture
|
||||||
|
|
||||||
|
Revision ID: c242e3f99c64
|
||||||
|
Revises: 286ee26b9e5d
|
||||||
|
Create Date: 2024-11-27 10:40:39.027786
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'c242e3f99c64'
|
||||||
|
down_revision = '286ee26b9e5d'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('team_discord_integrations', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('webhook_bot_profile_picture', sa.String(), nullable=True))
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('team_discord_integrations', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('webhook_bot_profile_picture')
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
|
@ -36,7 +36,6 @@ class Team(app_db.BaseModel):
|
||||||
|
|
||||||
def update_integrations(self, integrations: "TeamIntegrationSchema"):
|
def update_integrations(self, integrations: "TeamIntegrationSchema"):
|
||||||
if integrations.discord_integration:
|
if integrations.discord_integration:
|
||||||
print("DISCORD!!!")
|
|
||||||
discord_integration = self.discord_integration \
|
discord_integration = self.discord_integration \
|
||||||
or TeamDiscordIntegration()
|
or TeamDiscordIntegration()
|
||||||
discord_integration.webhook_url = integrations \
|
discord_integration.webhook_url = integrations \
|
||||||
|
@ -44,6 +43,10 @@ class Team(app_db.BaseModel):
|
||||||
discord_integration.webhook_bot_name = integrations \
|
discord_integration.webhook_bot_name = integrations \
|
||||||
.discord_integration.webhook_bot_name
|
.discord_integration.webhook_bot_name
|
||||||
|
|
||||||
|
if integrations.discord_integration.webhook_bot_profile_picture:
|
||||||
|
discord_integration.webhook_bot_profile_picture = integrations \
|
||||||
|
.discord_integration.webhook_bot_profile_picture
|
||||||
|
|
||||||
if discord_integration.team_id is None:
|
if discord_integration.team_id is None:
|
||||||
discord_integration.team_id = self.id
|
discord_integration.team_id = self.id
|
||||||
app_db.db.session.add(discord_integration)
|
app_db.db.session.add(discord_integration)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from typing import Optional
|
||||||
from sqlalchemy.orm import mapped_column, relationship
|
from sqlalchemy.orm import mapped_column, relationship
|
||||||
from sqlalchemy.orm.attributes import Mapped
|
from sqlalchemy.orm.attributes import Mapped
|
||||||
from sqlalchemy.orm.properties import ForeignKey
|
from sqlalchemy.orm.properties import ForeignKey
|
||||||
|
@ -12,18 +13,21 @@ class TeamDiscordIntegration(app_db.BaseModel):
|
||||||
team_id: Mapped[int] = mapped_column(ForeignKey("teams.id"), primary_key=True)
|
team_id: Mapped[int] = mapped_column(ForeignKey("teams.id"), primary_key=True)
|
||||||
webhook_url: Mapped[str] = mapped_column(String)
|
webhook_url: Mapped[str] = mapped_column(String)
|
||||||
webhook_bot_name: Mapped[str] = mapped_column(String)
|
webhook_bot_name: Mapped[str] = mapped_column(String)
|
||||||
|
webhook_bot_profile_picture: Mapped[str] = mapped_column(String(255), nullable=True)
|
||||||
|
|
||||||
team: Mapped["Team"] = relationship("Team", back_populates="discord_integration")
|
team: Mapped["Team"] = relationship("Team", back_populates="discord_integration")
|
||||||
|
|
||||||
class TeamDiscordIntegrationSchema(spec.BaseModel):
|
class TeamDiscordIntegrationSchema(spec.BaseModel):
|
||||||
webhook_url: str
|
webhook_url: str
|
||||||
webhook_bot_name: str
|
webhook_bot_name: str
|
||||||
|
webhook_bot_profile_picture: Optional[str]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_model(cls, model: TeamDiscordIntegration) -> "TeamDiscordIntegrationSchema":
|
def from_model(cls, model: TeamDiscordIntegration) -> "TeamDiscordIntegrationSchema":
|
||||||
return cls(
|
return cls(
|
||||||
webhook_url=model.webhook_url,
|
webhook_url=model.webhook_url,
|
||||||
webhook_bot_name=model.webhook_bot_name,
|
webhook_bot_name=model.webhook_bot_name,
|
||||||
|
webhook_bot_profile_picture=model.webhook_bot_profile_picture,
|
||||||
)
|
)
|
||||||
|
|
||||||
class TeamLogsTfIntegration(app_db.BaseModel):
|
class TeamLogsTfIntegration(app_db.BaseModel):
|
||||||
|
|
Loading…
Reference in New Issue