diff --git a/files/classes/comment.py b/files/classes/comment.py index d16b8e0fe..e08924219 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -34,7 +34,7 @@ class Comment(Base): over_18 = Column(Boolean, default=False) is_bot = Column(Boolean, default=False) is_pinned = Column(String(25)) - sentto=Column(Integer) + sentto=Column(Integer, ForeignKey("users.id")) notifiedto=Column(Integer) app_id = Column(Integer, ForeignKey("oauth_apps.id")) oauth_app = relationship("OauthApp", viewonly=True) @@ -47,6 +47,7 @@ class Comment(Base): post = relationship("Submission", viewonly=True) flags = relationship("CommentFlag", lazy="dynamic", viewonly=True) author = relationship("User", primaryjoin="User.id==Comment.author_id") + sendtouser = relationship("User", primaryjoin="User.id==Comment.sentto") parent_comment = relationship("Comment", remote_side=[id], viewonly=True) child_comments = relationship("Comment", remote_side=[parent_comment_id], viewonly=True) awards = relationship("AwardRelationship", viewonly=True) diff --git a/files/routes/users.py b/files/routes/users.py index da52521f0..ee9b246a8 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -227,7 +227,6 @@ def message2(v, username): message = request.values.get("message", "")[:1000].strip() - # check existing existing = g.db.query(Comment).options(lazyload('*')).filter(Comment.author_id == v.id, Comment.sentto == user.id, Comment.body == message, diff --git a/files/templates/comments.html b/files/templates/comments.html index 9830382dd..a161a4880 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -175,7 +175,7 @@ {% elif c.author_id==NOTIFICATIONS_ACCOUNT or c.author_id==AUTOJANNY_ACCOUNT %} {{'SITE_NAME' | app_config}} Notification {% else %} - Private Message + Sent to @{{c.senttouser}} {% endif %}