مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2026-01-18 05:49:47 +00:00
initial commit from appmail
هذا الالتزام موجود في:
54
app/models/user_invite.rb
Normal file
54
app/models/user_invite.rb
Normal file
@@ -0,0 +1,54 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: user_invites
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# uuid :string(255)
|
||||
# email_address :string(255)
|
||||
# expires_at :datetime
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_user_invites_on_uuid (uuid)
|
||||
#
|
||||
|
||||
class UserInvite < ApplicationRecord
|
||||
|
||||
include HasUUID
|
||||
|
||||
validates :email_address, :presence => true, :uniqueness => true, :format => {:with => /@/, :allow_blank => true}
|
||||
|
||||
has_many :organization_users, :dependent => :destroy, :as => :user
|
||||
has_many :organizations, :through => :organization_users
|
||||
|
||||
default_value :expires_at, -> { 7.days.from_now }
|
||||
|
||||
def md5_for_gravatar
|
||||
@md5_for_gravatar ||= Digest::MD5.hexdigest(email_address.to_s.downcase)
|
||||
end
|
||||
|
||||
def avatar_url
|
||||
@avatar_url ||= email_address ? "https://secure.gravatar.com/avatar/#{md5_for_gravatar}?rating=PG&size=120&d=mm" : nil
|
||||
end
|
||||
|
||||
def name
|
||||
email_address
|
||||
end
|
||||
|
||||
def accept(user)
|
||||
transaction do
|
||||
self.organization_users.each do |ou|
|
||||
ou.update(:user => user) || ou.destroy
|
||||
end
|
||||
self.organization_users.reload
|
||||
self.destroy
|
||||
end
|
||||
end
|
||||
|
||||
def reject
|
||||
self.destroy
|
||||
end
|
||||
|
||||
end
|
||||
المرجع في مشكلة جديدة
حظر مستخدم