mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-20 11:45:57 +08:00
新增:项目邀请链接增加时间限制,以及show_link接口新增
This commit is contained in:
@@ -35,7 +35,8 @@ class ProjectInviteLink < ApplicationRecord
|
||||
before_create :set_old_data_expired_at
|
||||
|
||||
def self.random_hex_sign
|
||||
SecureRandom.hex
|
||||
hex = (SecureRandom.hex(32))
|
||||
return hex unless ProjectInviteLink.where(sign: hex).exists?
|
||||
end
|
||||
|
||||
def self.build!(project, user, role="developer", is_apply=true)
|
||||
@@ -44,13 +45,14 @@ class ProjectInviteLink < ApplicationRecord
|
||||
user_id: user&.id,
|
||||
role: role,
|
||||
is_apply: is_apply,
|
||||
sign: random_hex_sign
|
||||
sign: random_hex_sign,
|
||||
expired_at: Time.now + 3.days
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
def set_old_data_expired_at
|
||||
ProjectInviteLink.where(user_id: self.user_id, project_id: self.project).update_all(expired_at: Time.now)
|
||||
ProjectInviteLink.where(user_id: self.user_id, project_id: self.project, role: self.role, is_apply: self.is_apply).update_all(expired_at: Time.now)
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user