diff options
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/bangtags.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb index d1a179a76..0567caf6d 100644 --- a/app/lib/bangtags.rb +++ b/app/lib/bangtags.rb @@ -235,6 +235,40 @@ class Bangtags mentions = Account.where(id: mention_ids).map { |a| "@#{a.username}" } chunk = mentions.join(' ') end + when 'sharekey' + case cmd[2] + when 'revoke' + if status.conversation_id.present? + roars = Status.where(conversation_id: status.conversation_id, account_id: @account.id) + roars.each do |roar| + if roar.sharekey.present? + roar.sharekey = nil + roar.save + end + end + end + when 'sync', 'new' + if status.conversation_id.present? + roars = Status.where(conversation_id: status.conversation_id, account_id: @account.id) + earliest_roar = roars.last # The results are in reverse-chronological order. + if cmd[2] == 'new' || earlist_roar.sharekey.blank? + sharekey = SecureRandom.urlsafe_base64(32) + earliest_roar.sharekey = sharekey + earliest_roar.save + else + sharekey = earliest_roar.sharekey + end + roars.each do |roar| + if roar.sharekey != sharekey + roar.sharekey = sharekey + roar.save + end + end + else + status.sharekey = SecureRandom.urlsafe_base64(32) + status.save + end + end end when 'parent' chunk = nil @@ -326,6 +360,13 @@ class Bangtags end @vars['_they:are'] = name.strip end + when 'sharekey' + case cmd[1] + when 'new' + chunk = nil + status.sharekey = SecureRandom.urlsafe_base64(32) + status.save + end end end |