# Copyright (c) 2010, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. module RakeHelpers def process_emails(csv, num_to_process, offset, num_invites=10, test=true) if RUBY_VERSION.include? "1.8" require 'fastercsv' backers = FasterCSV.read(csv) else require 'csv' backers = CSV.read(csv) end puts "IN TEST MODE" if test churn_through = 0 num_to_process.times do |n| if backers[n+offset] == nil break end churn_through = n backer_name = backers[n+offset][0].to_s.strip backer_email = backers[n+offset][1].to_s.gsub('.ksr', '').strip unless User.find_by_email(backer_email) puts "sending email to: #{backer_name} #{backer_email}" unless Rails.env == 'test' Invitation.create_invitee(:email => backer_email, :name => backer_name, :invites => num_invites) unless test else puts "user with the email exists: #{backer_email} , #{backer_name} " unless Rails.env == 'test' end end churn_through end def fix_diaspora_handle_spaces(test = true) offenders = {} space_people = Person.all(:diaspora_handle => / /, :url => APP_CONFIG[:pod_url]) # this is every person with a space.... #these people dont even have users.... they are totally messed up totally_messed_up_people = space_people.find_all{|x| x.owner.nil?} totally_messed_up_people.each{|x| x.delete} space_people = Person.all(:diaspora_handle => / /, :owner_id.ne => nil, :url => APP_CONFIG[:pod_url]) # this is every person with a space.... space_people.each do |person| user = person.owner new_diaspora_handle = "#{user.username}@#{APP_CONFIG[:pod_uri].host}" user.my_posts.all.each do |post| post.diaspora_handle = new_diaspora_handle if test (puts "TEST: saving post w/id #{post.id}") else post.save(:safe => true) end end person.diaspora_handle = new_diaspora_handle if test (puts "TEST:saving person w/handle #{person.diaspora_handle}") else person.save(:safe => true) end mail = <