Skip to content

Commit

Permalink
Merge pull request #2497 from data-for-change/dev
Browse files Browse the repository at this point in the history
merge dev into master
  • Loading branch information
atalyaalon authored Dec 6, 2023
2 parents c73b998 + a263185 commit 6b1174a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
32 changes: 32 additions & 0 deletions alembic/versions/881e7b1dba8a_track_telegram_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""track telegram messages
Revision ID: 881e7b1dba8a
Revises: 664f8a93794e
Create Date: 2023-11-21 12:39:32.931262
"""

# revision identifiers, used by Alembic.
revision = '881e7b1dba8a'
down_revision = '664f8a93794e'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa

def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('telegram_forwarded_messages',
sa.Column('message_id', sa.String(), nullable=True),
sa.Column('newsflash_id', sa.Integer(), nullable=False),
sa.Column('group_sent', sa.String(), nullable=False),
sa.PrimaryKeyConstraint('message_id')
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('telegram_forwarded_messages')
# ### end Alembic commands ###
8 changes: 8 additions & 0 deletions anyway/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,14 @@ def embedded_reports_api():
return response


@app.route("/api/telegram/webhook", methods=["POST"])
def telegram_webhook():
update = request.json # Telegram sends updates in JSON format
logging.info(f"Received Telegram update: {update}")

return jsonify(success=True)


# User system API
app.add_url_rule("/user/add_role", view_func=add_role, methods=["POST"])
app.add_url_rule(
Expand Down
6 changes: 6 additions & 0 deletions anyway/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2975,3 +2975,9 @@ class TelegramGroups(TelegramGroupsBase):

class TelegramGroupsTest(TelegramGroupsBase):
__tablename__ = "telegram_groups_test"

class TelegramForwardedMessages():
__tablename__ = 'telegram_forwarded_messages'
message_id = Column(String(), primary_key=True)
newsflash_id = Column(BigInteger(), nullable=False)
group_sent = Column(String(), nullable=False),
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ rauth==0.7.3
rcssmin==1.0.6
requests==2.31.0
tweepy==3.8.0
urllib3==1.26.17
urllib3==1.26.18
webassets==2.0
xlrd==2.0.1
lxml==4.9.1
Expand Down

0 comments on commit 6b1174a

Please sign in to comment.