Python backend for a Slack's kudos plugin.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

update messages

+24 -5
+3 -1
kefi/routers/helpers.py
··· 27 27 from kefi.models.plazas.helpers import ( 28 28 create_attendance, 29 29 delete_attendance, 30 + get_or_create_current_plaza, 30 31 is_attending, 31 32 ) 32 33 from kefi.routers.messages import ( ··· 212 213 def _view_submission_meet_join(self, view_id: str) -> list | dict: 213 214 """Joins the plaza.""" 214 215 message: BaseMessage 216 + next_plaza = get_or_create_current_plaza(session=self.session) 215 217 try: 216 218 create_attendance(user=self.user, session=self.session) 217 - message = UserJoinedMeetMessage() 219 + message = UserJoinedMeetMessage(plaza=next_plaza) 218 220 self.slack.post_message_user( 219 221 user_id=self.user.slack_user_id, 220 222 blocks=message.blocks(),
+19 -2
kefi/routers/messages.py
··· 2 2 Block, 3 3 ButtonElement, 4 4 DividerBlock, 5 + ImageElement, 5 6 MarkdownTextObject, 6 7 PlainTextObject, 7 8 SectionBlock, 8 9 ) 9 10 10 11 from kefi.constants import Actions 12 + from kefi.models.database import Plaza 11 13 12 14 13 15 class BaseMessage: ··· 19 21 20 22 21 23 class UserJoinedMeetMessage(BaseMessage): 24 + def __init__(self, plaza: Plaza): 25 + self.plaza = plaza 26 + 22 27 def text(self) -> str: 23 28 return ":tada: ¡Genial! ¡Nos vemos el próximo viernes!" 24 29 25 30 def blocks(self) -> list[Block]: 31 + date = self.plaza.local_date() 32 + 26 33 return [ 27 34 SectionBlock( 28 35 text=MarkdownTextObject( ··· 31 38 ), 32 39 DividerBlock(), 33 40 SectionBlock( 41 + text=MarkdownTextObject( 42 + text=f"*Próximo encuentro*\n{date.strftime('%A, %-d %B')}\n{date.strftime('%H:%M')}\n" 43 + ), 44 + accessory=ImageElement( 45 + image_url="https://storage.staging.dekaside.com/kefi/static/images/kefi_plaza.png", 46 + alt_text="Kefi Plaza imagen", 47 + ), 48 + ), 49 + DividerBlock(), 50 + SectionBlock( 34 51 text=MarkdownTextObject(text="¿Cambio de planes?"), 35 52 accessory=ButtonElement( 36 53 text=PlainTextObject(text="No asistiré"), ··· 72 89 73 90 74 91 class NotAttendingMessage(BaseMessage): 75 - def text(self) -> str: 92 + def text(self, *args, **kwargs) -> str: 76 93 return "NotAttendingMessage" 77 94 78 - def blocks(self) -> list[Block]: 95 + def blocks(self, *args, **kwargs) -> list[Block]: 79 96 return [SectionBlock(text="NotAttendingMessage")]
+2 -2
kefi/routers/views.py
··· 39 39 text=f"*Próximo encuentro*\n{date.strftime('%A, %-d %B')}\n{date.strftime('%H:%M')}\n" 40 40 ), 41 41 accessory=ImageElement( 42 - image_url="https://api.slack.com/img/blocks/bkb_template_images/notifications.png", 43 - alt_text="calendar thumbnail", 42 + image_url="https://storage.staging.dekaside.com/kefi/static/images/kefi_plaza.png", 43 + alt_text="Kefi Plaza imagen", 44 44 ), 45 45 ), 46 46 ],