diff --git a/lib/mastodon.py b/lib/mastodon.py index 7101bc3..ce105af 100644 --- a/lib/mastodon.py +++ b/lib/mastodon.py @@ -124,7 +124,6 @@ def post_from_api_object(obj, instance): return Post( mastodon_instance = instance, mastodon_id = obj['id'], - body = obj['content'], favourite = obj['favourited'], has_media = 'media_attachments' in obj and bool(obj['media_attachments']), created_at = iso8601.parse_date(obj['created_at']), diff --git a/lib/twitter.py b/lib/twitter.py index 49a371c..1c58650 100644 --- a/lib/twitter.py +++ b/lib/twitter.py @@ -90,10 +90,6 @@ def post_from_api_tweet_object(tweet, post=None): except ValueError: post.created_at = datetime.strptime(tweet['created_at'], '%Y-%m-%d %H:%M:%S %z') #whyyy - if 'full_text' in tweet: - post.body = tweet['full_text'] - else: - post.body = tweet['text'] post.author_id = 'twitter:{}'.format(tweet['user']['id_str']) if 'favorited' in tweet: post.favourite = tweet['favorited'] diff --git a/migrations/versions/8993e80e7aa3_remove_post_body.py b/migrations/versions/8993e80e7aa3_remove_post_body.py new file mode 100644 index 0000000..f21a3cf --- /dev/null +++ b/migrations/versions/8993e80e7aa3_remove_post_body.py @@ -0,0 +1,24 @@ +"""remove post body + +Revision ID: 8993e80e7aa3 +Revises: c80af843eed3 +Create Date: 2017-08-20 18:04:28.516129 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '8993e80e7aa3' +down_revision = 'c80af843eed3' +branch_labels = None +depends_on = None + + +def upgrade(): + op.drop_column('posts', 'body') + + +def downgrade(): + op.add_column('posts', sa.Column('body', sa.VARCHAR(), autoincrement=False, nullable=True)) diff --git a/model.py b/model.py index 72fd7bd..8bff012 100644 --- a/model.py +++ b/model.py @@ -169,7 +169,6 @@ class Post(db.Model, TimestampMixin, RemoteIDMixin): __tablename__ = 'posts' id = db.Column(db.String, primary_key=True) - body = db.Column(db.String) author_id = db.Column(db.String, db.ForeignKey('accounts.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False) author = db.relationship(Account, @@ -178,13 +177,8 @@ class Post(db.Model, TimestampMixin, RemoteIDMixin): favourite = db.Column(db.Boolean, server_default='FALSE', nullable=False) has_media = db.Column(db.Boolean, server_default='FALSE', nullable=False) - def snippet(self): - if len(self.body) > 20: - return self.body[:19] + "✂" - return self.body - def __repr__(self): - return ''.format(self.id, self.snippet(), self.author_id) + return ''.format(self.id, self.author_id) db.Index('ix_posts_author_id_created_at', Post.author_id, Post.created_at)