mods/standard/sets/all/follow.rb in wagn-1.12.13 vs mods/standard/sets/all/follow.rb in wagn-1.13.0.pre

- old
+ new

@@ -1,8 +1,8 @@ format :html do - watch_perms = lambda { |r| Account.logged_in? && !r.card.new_card? } + watch_perms = lambda { |r| Auth.signed_in? && !r.card.new_card? } view :watch, :tags=>[:unknown_ok, :no_wrap_comments], :denial=>:blank, :perms=>watch_perms do |args| wrap args do if card.watching_type? watching_type_cards @@ -36,21 +36,25 @@ @watcher_watched_pairs = watcher_watched_pairs end event :notify_followers, :after=>:extend do begin - return false if Card.record_timestamps==false or Wagn.config.send_emails==false + return false if Card.record_timestamps==false # userstamps and timestamps are turned off in cases like updating read_rules that are automated and # generally not of enough interest to warrant notification action = "#{@action}d" @trunk_watcher_watched_pairs ||= trunk_watcher_watched_pairs @watcher_watched_pairs ||= watcher_watched_pairs - @watcher_watched_pairs.reject {|p| @trunk_watcher_watched_pairs.map(&:first).include? p.first }.each do |watcher, watched| - watcher and mail = Mailer.change_notice( watcher, self, action, watched.to_s, nested_notifications ) and mail.deliver + @watcher_watched_pairs.reject do |p| + @trunk_watcher_watched_pairs.map(&:first).include? p.first + end.each do |watcher, watched| + watcher and + mail = Mailer.change_notice( watcher, self, action, watched.to_s, nested_notifications ) and + mail.deliver end if @supercard @supercard.nested_notifications ||= [] @supercard.nested_notifications << [ name, action ] @@ -70,22 +74,20 @@ attr_accessor :nested_notifications def trunk_watcher_watched_pairs # do the watchers lookup before the includer test since it's faster. if cardname.junction? - #warn "trunk_watcher_pairs #{cardname}, #{cardname.trunk_name.inspect}, #{includers.inspect}" tcard = Card[tname=cardname.trunk_name] tcard and pairs = tcard.watcher_watched_pairs - #warn "trunk_watcher_pairs TC:#{tcard.inspect}, #{tname}, P:#{pairs.inspect}, k:#{tname.key} member: pr:#{!pairs.nil?}, and I:#{includers.map(&:key).member?(tname.key)}" + #fixme - includers not working on structured cards, so this is commented for now return pairs if !pairs.nil? and includers.map(&:key).member?(tname.key) - #warn "twatch empty ..." end [] end -def watching_type?; watcher_pairs(false, :type).member? Account.current_id end -def watching?; watcher_pairs(false). member? Account.current_id end +def watching_type?; watcher_pairs(false, :type).member? Auth.current_id end +def watching?; watcher_pairs(false). member? Auth.current_id end def watchers watcher_watched_pairs false end @@ -93,21 +95,21 @@ watcher_pairs pairs, :name, whash = {} watcher_pairs pairs, :type, whash end def watcher_pairs pairs=true, kind=:name, hash={} - #warn "wp #{inspect} P:#{pairs}, k:#{kind}, uid:#{Account.current_id} #{hash.inspect}, OI:#{hash.object_id}" + #warn "wp #{inspect} P:#{pairs}, k:#{kind}, uid:#{Auth.current_id} #{hash.inspect}, OI:#{hash.object_id}" wname, rc = (kind == :type) ? [ self.type_name, self.type_card.fetch(:trait=>:watchers) ] : [ self.cardname, fetch(:trait=>:watchers) ] !rc.nil? and hash = rc.item_cards.inject( hash ) { |h, watcher| h[watcher.id] ||= wname; h } if hash.any? #warn "wp #{pairs}, #{kind}, #{hash.inspect}" if pairs - hash.each.reject {|i,wname| i == Account.current_id }.map {|i,wname| [ i, wname ] } + hash.each.reject {|i,wname| i == Auth.current_id }.map {|i,wname| [ i, wname ] } else hash.keys end else []