refactor to remove rekeyedAt and use group current key
This commit is contained in:
parent
2536d9c8ba
commit
d60beb2283
|
@ -1042,6 +1042,11 @@ func (s *MessageSender) StartDatasync() {
|
|||
s.datasync = ds
|
||||
}
|
||||
|
||||
// GetCurrentKeyForGroup returns the latest key timestampID belonging to a key group
|
||||
func (s *MessageSender) GetCurrentKeyForGroup(groupID []byte) (uint32, error) {
|
||||
return s.protocol.GetCurrentKeyForGroup(groupID)
|
||||
}
|
||||
|
||||
// GetKeyIDsForGroup returns a slice of key IDs belonging to a given group ID
|
||||
func (s *MessageSender) GetKeyIDsForGroup(groupID []byte) ([]uint32, error) {
|
||||
return s.protocol.GetKeyIDsForGroup(groupID)
|
||||
|
|
|
@ -40,7 +40,6 @@ type Config struct {
|
|||
RequestsToJoin []*RequestToJoin
|
||||
MemberIdentity *ecdsa.PublicKey
|
||||
SyncedAt uint64
|
||||
RekeyedAt time.Time
|
||||
EventsData *EventsData
|
||||
}
|
||||
|
||||
|
@ -1967,11 +1966,6 @@ func (o *Community) SetActiveMembersCount(activeMembersCount uint64) (updated bo
|
|||
return true, nil
|
||||
}
|
||||
|
||||
// RekeyedAt returns the RekeyedAt value from the underlying Community.config
|
||||
func (o *Community) RekeyedAt() time.Time {
|
||||
return o.config.RekeyedAt
|
||||
}
|
||||
|
||||
type sortSlice []sorterHelperIdx
|
||||
type sorterHelperIdx struct {
|
||||
pos int32
|
||||
|
|
|
@ -4029,15 +4029,3 @@ func (m *Manager) saveAndPublish(community *Community) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetRekeyedAtClock returns the rekeyed_at time of a given community
|
||||
// exposes persistence level functionality to exported Manager APIs
|
||||
func (m *Manager) GetRekeyedAtClock(id []byte) (time.Time, error) {
|
||||
return m.persistence.GetRekeyedAtClock(id)
|
||||
}
|
||||
|
||||
// SetRekeyedAtClock sets the rekeyed_at time value of a given community
|
||||
// exposes persistence level functionality to exported Manager APIs
|
||||
func (m *Manager) SetRekeyedAtClock(id []byte, time time.Time) error {
|
||||
return m.persistence.SetRekeyedAtClock(id, time)
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ var ErrOldRequestToLeave = errors.New("old request to leave")
|
|||
|
||||
const OR = " OR "
|
||||
const communitiesBaseQuery = `
|
||||
SELECT c.id, c.private_key, c.description, c.joined, c.spectated, c.verified, c.muted, c.muted_till, c.rekeyed_at, r.clock, ae.raw_events, ae.raw_description
|
||||
SELECT c.id, c.private_key, c.description, c.joined, c.spectated, c.verified, c.muted, c.muted_till, r.clock, ae.raw_events, ae.raw_description
|
||||
FROM communities_communities c
|
||||
LEFT JOIN communities_requests_to_join r ON c.id = r.community_id AND r.public_key = ?
|
||||
LEFT JOIN communities_events ae ON c.id = ae.id`
|
||||
|
@ -139,16 +139,15 @@ func (p *Persistence) queryCommunities(memberIdentity *ecdsa.PublicKey, query st
|
|||
var joined, spectated, verified, muted bool
|
||||
var muteTill sql.NullTime
|
||||
var requestedToJoinAt sql.NullInt64
|
||||
var rekeyedAt sql.NullTime
|
||||
|
||||
// Community events specific fields
|
||||
var eventsBytes, eventsDescriptionBytes []byte
|
||||
err := rows.Scan(&publicKeyBytes, &privateKeyBytes, &descriptionBytes, &joined, &spectated, &verified, &muted, &muteTill, &rekeyedAt, &requestedToJoinAt, &eventsBytes, &eventsDescriptionBytes)
|
||||
err := rows.Scan(&publicKeyBytes, &privateKeyBytes, &descriptionBytes, &joined, &spectated, &verified, &muted, &muteTill, &requestedToJoinAt, &eventsBytes, &eventsDescriptionBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
org, err := unmarshalCommunityFromDB(memberIdentity, publicKeyBytes, privateKeyBytes, descriptionBytes, joined, spectated, verified, muted, muteTill.Time, rekeyedAt.Time, uint64(requestedToJoinAt.Int64), eventsBytes, eventsDescriptionBytes, p.logger)
|
||||
org, err := unmarshalCommunityFromDB(memberIdentity, publicKeyBytes, privateKeyBytes, descriptionBytes, joined, spectated, verified, muted, muteTill.Time, uint64(requestedToJoinAt.Int64), eventsBytes, eventsDescriptionBytes, p.logger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -190,7 +189,7 @@ func (p *Persistence) rowsToCommunities(memberIdentity *ecdsa.PublicKey, rows *s
|
|||
// Community specific fields
|
||||
var publicKeyBytes, privateKeyBytes, descriptionBytes []byte
|
||||
var joined, spectated, verified, muted bool
|
||||
var muteTill, rekeyedAt sql.NullTime
|
||||
var muteTill sql.NullTime
|
||||
|
||||
// Request to join specific fields
|
||||
var rtjID, rtjCommunityID []byte
|
||||
|
@ -201,13 +200,13 @@ func (p *Persistence) rowsToCommunities(memberIdentity *ecdsa.PublicKey, rows *s
|
|||
var eventsBytes, eventsDescriptionBytes []byte
|
||||
|
||||
err = rows.Scan(
|
||||
&publicKeyBytes, &privateKeyBytes, &descriptionBytes, &joined, &spectated, &verified, &muted, &muteTill, &rekeyedAt,
|
||||
&publicKeyBytes, &privateKeyBytes, &descriptionBytes, &joined, &spectated, &verified, &muted, &muteTill,
|
||||
&rtjID, &rtjPublicKey, &rtjClock, &rtjENSName, &rtjChatID, &rtjCommunityID, &rtjState, &eventsBytes, &eventsDescriptionBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
comm, err = unmarshalCommunityFromDB(memberIdentity, publicKeyBytes, privateKeyBytes, descriptionBytes, joined, spectated, verified, muted, muteTill.Time, rekeyedAt.Time, uint64(rtjClock.Int64), eventsBytes, eventsDescriptionBytes, p.logger)
|
||||
comm, err = unmarshalCommunityFromDB(memberIdentity, publicKeyBytes, privateKeyBytes, descriptionBytes, joined, spectated, verified, muted, muteTill.Time, uint64(rtjClock.Int64), eventsBytes, eventsDescriptionBytes, p.logger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -224,7 +223,7 @@ func (p *Persistence) rowsToCommunities(memberIdentity *ecdsa.PublicKey, rows *s
|
|||
|
||||
func (p *Persistence) JoinedAndPendingCommunitiesWithRequests(memberIdentity *ecdsa.PublicKey) (comms []*Community, err error) {
|
||||
query := `SELECT
|
||||
c.id, c.private_key, c.description, c.joined, c.spectated, c.verified, c.muted, c.muted_till, c.rekeyed_at,
|
||||
c.id, c.private_key, c.description, c.joined, c.spectated, c.verified, c.muted, c.muted_till,
|
||||
r.id, r.public_key, r.clock, r.ens_name, r.chat_id, r.community_id, r.state, ae.raw_events, ae.raw_description
|
||||
FROM communities_communities c
|
||||
LEFT JOIN communities_requests_to_join r ON c.id = r.community_id AND r.public_key = ?
|
||||
|
@ -241,7 +240,7 @@ WHERE c.Joined OR r.state = ?`
|
|||
|
||||
func (p *Persistence) DeletedCommunities(memberIdentity *ecdsa.PublicKey) (comms []*Community, err error) {
|
||||
query := `SELECT
|
||||
c.id, c.private_key, c.description, c.joined, c.spectated, c.verified, c.muted, c.muted_till, c.rekeyed_at,
|
||||
c.id, c.private_key, c.description, c.joined, c.spectated, c.verified, c.muted, c.muted_till,
|
||||
r.id, r.public_key, r.clock, r.ens_name, r.chat_id, r.community_id, r.state, ae.raw_events, ae.raw_description
|
||||
FROM communities_communities c
|
||||
LEFT JOIN communities_requests_to_join r ON c.id = r.community_id AND r.public_key = ?
|
||||
|
@ -268,25 +267,23 @@ func (p *Persistence) GetByID(memberIdentity *ecdsa.PublicKey, id []byte) (*Comm
|
|||
var verified bool
|
||||
var muted bool
|
||||
var muteTill sql.NullTime
|
||||
var rekeyed sql.NullTime
|
||||
var requestedToJoinAt sql.NullInt64
|
||||
var rekeyedAt sql.NullTime
|
||||
|
||||
// Community events specific fields
|
||||
var eventsBytes, eventsDescriptionBytes []byte
|
||||
|
||||
err := p.db.QueryRow(communitiesBaseQuery+` WHERE c.id = ?`, common.PubkeyToHex(memberIdentity), id).Scan(&publicKeyBytes, &privateKeyBytes, &descriptionBytes, &joined, &spectated, &verified, &muted, &muteTill, &rekeyedAt, &requestedToJoinAt, &eventsBytes, &eventsDescriptionBytes)
|
||||
err := p.db.QueryRow(communitiesBaseQuery+` WHERE c.id = ?`, common.PubkeyToHex(memberIdentity), id).Scan(&publicKeyBytes, &privateKeyBytes, &descriptionBytes, &joined, &spectated, &verified, &muted, &muteTill, &requestedToJoinAt, &eventsBytes, &eventsDescriptionBytes)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return unmarshalCommunityFromDB(memberIdentity, publicKeyBytes, privateKeyBytes, descriptionBytes, joined, spectated, verified, muted, muteTill.Time, rekeyed.Time, uint64(requestedToJoinAt.Int64), eventsBytes, eventsDescriptionBytes, p.logger)
|
||||
return unmarshalCommunityFromDB(memberIdentity, publicKeyBytes, privateKeyBytes, descriptionBytes, joined, spectated, verified, muted, muteTill.Time, uint64(requestedToJoinAt.Int64), eventsBytes, eventsDescriptionBytes, p.logger)
|
||||
}
|
||||
|
||||
func unmarshalCommunityFromDB(memberIdentity *ecdsa.PublicKey, publicKeyBytes, privateKeyBytes, descriptionBytes []byte, joined,
|
||||
spectated, verified, muted bool, muteTill time.Time, rekeyedAt time.Time, requestedToJoinAt uint64, eventsBytes []byte,
|
||||
spectated, verified, muted bool, muteTill time.Time, requestedToJoinAt uint64, eventsBytes []byte,
|
||||
eventsDescriptionBytes []byte, logger *zap.Logger) (*Community, error) {
|
||||
|
||||
var privateKey *ecdsa.PrivateKey
|
||||
|
@ -327,7 +324,6 @@ func unmarshalCommunityFromDB(memberIdentity *ecdsa.PublicKey, publicKeyBytes, p
|
|||
RequestedToJoinAt: requestedToJoinAt,
|
||||
Joined: joined,
|
||||
Spectated: spectated,
|
||||
RekeyedAt: rekeyedAt,
|
||||
EventsData: eventsData,
|
||||
}
|
||||
community, err := New(config)
|
||||
|
@ -1271,18 +1267,3 @@ func decodeEventsData(eventsBytes []byte, eventsDescriptionBytes []byte) (*Event
|
|||
Events: events,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetRekeyedAtClock returns the rekeyed_at time of a given community
|
||||
func (p *Persistence) GetRekeyedAtClock(id []byte) (rekeyedAt time.Time, err error) {
|
||||
err = p.db.QueryRow(`SELECT rekeyed_at FROM communities_communities WHERE id = ?`, id).Scan(&rekeyedAt)
|
||||
if err != nil {
|
||||
return rekeyedAt, err
|
||||
}
|
||||
return rekeyedAt, nil
|
||||
}
|
||||
|
||||
// SetRekeyedAtClock sets the rekeyed_at time value of a given community
|
||||
func (p *Persistence) SetRekeyedAtClock(id []byte, time time.Time) error {
|
||||
_, err := p.db.Exec(`UPDATE communities_communities SET rekeyed_at = ? WHERE id = ? AND rekeyed_at < ?`, time, id, time)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -471,43 +471,3 @@ func (s *PersistenceSuite) TestSaveCheckChannelPermissionResponse() {
|
|||
s.Require().Equal(responses[chatID].ViewAndPostPermissions.Permissions["one"].Criteria, []bool{true, true, true, true})
|
||||
s.Require().Equal(responses[chatID].ViewAndPostPermissions.Permissions["two"].Criteria, []bool{false})
|
||||
}
|
||||
|
||||
func (s *PersistenceSuite) TestGetRekeyedAtClock() {
|
||||
key, err := crypto.GenerateKey()
|
||||
s.Require().NoError(err)
|
||||
|
||||
// there is one community inserted by default
|
||||
communities, err := s.db.AllCommunities(&key.PublicKey)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Len(communities, 1)
|
||||
|
||||
community := &Community{
|
||||
config: &Config{
|
||||
PrivateKey: key,
|
||||
ID: &key.PublicKey,
|
||||
Joined: true,
|
||||
Spectated: true,
|
||||
Verified: true,
|
||||
CommunityDescription: &protobuf.CommunityDescription{},
|
||||
},
|
||||
}
|
||||
s.Require().NoError(s.db.SaveCommunity(community))
|
||||
|
||||
communities, err = s.db.AllCommunities(&key.PublicKey)
|
||||
c := communities[1]
|
||||
s.Require().NoError(err)
|
||||
s.Require().Len(communities, 2)
|
||||
s.Equal(types.HexBytes(crypto.CompressPubkey(&key.PublicKey)), c.ID())
|
||||
s.True(c.Joined())
|
||||
s.True(c.Spectated())
|
||||
s.True(c.Verified())
|
||||
s.Zero(c.config.RekeyedAt.Unix())
|
||||
|
||||
now := time.Now()
|
||||
err = s.db.SetRekeyedAtClock(c.ID(), now)
|
||||
s.Require().NoError(err)
|
||||
|
||||
then, err := s.db.GetRekeyedAtClock(c.ID())
|
||||
s.Require().NoError(err)
|
||||
s.Require().True(now.Equal(then))
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package communities
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
)
|
||||
|
@ -16,11 +15,9 @@ type RawCommunityRow struct {
|
|||
Verified bool
|
||||
SyncedAt uint64
|
||||
Muted bool
|
||||
RekeyedAt time.Time
|
||||
}
|
||||
|
||||
func fromSyncCommunityProtobuf(syncCommProto *protobuf.SyncCommunity) RawCommunityRow {
|
||||
// TODO handle rekeyedAt value
|
||||
return RawCommunityRow{
|
||||
ID: syncCommProto.Id,
|
||||
Description: syncCommProto.Description,
|
||||
|
@ -34,7 +31,7 @@ func fromSyncCommunityProtobuf(syncCommProto *protobuf.SyncCommunity) RawCommuni
|
|||
|
||||
func (p *Persistence) scanRowToStruct(rowScan func(dest ...interface{}) error) (*RawCommunityRow, error) {
|
||||
rcr := new(RawCommunityRow)
|
||||
var syncedAt, muteTill, rekeyedAt sql.NullTime
|
||||
var syncedAt, muteTill sql.NullTime
|
||||
|
||||
err := rowScan(
|
||||
&rcr.ID,
|
||||
|
@ -45,15 +42,11 @@ func (p *Persistence) scanRowToStruct(rowScan func(dest ...interface{}) error) (
|
|||
&rcr.Spectated,
|
||||
&rcr.Muted,
|
||||
&muteTill,
|
||||
&rekeyedAt,
|
||||
&syncedAt,
|
||||
)
|
||||
if syncedAt.Valid {
|
||||
rcr.SyncedAt = uint64(syncedAt.Time.Unix())
|
||||
}
|
||||
if rekeyedAt.Valid {
|
||||
rcr.RekeyedAt = rekeyedAt.Time
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -3445,7 +3445,7 @@ func (s *MessengerCommunitiesSuite) TestStartCommunityRekeyLoop() {
|
|||
c, err := s.admin.GetCommunityByID(response.Communities()[0].ID())
|
||||
s.Require().NoError(err)
|
||||
s.Require().False(c.Encrypted())
|
||||
s.Require().Zero(c.RekeyedAt().Unix())
|
||||
// TODO some check that there are no keys for the community. Alt for s.Require().Zero(c.RekeyedAt().Unix())
|
||||
|
||||
// Update the community to use encryption and check the values
|
||||
err = s.admin.UpdateCommunityEncryption(c, true)
|
||||
|
@ -3475,18 +3475,19 @@ func (s *MessengerCommunitiesSuite) TestStartCommunityRekeyLoop() {
|
|||
s.Require().True(c.HasMember(&s.alice.identity.PublicKey))
|
||||
s.Require().True(c.HasMember(&s.bob.identity.PublicKey))
|
||||
|
||||
// TODO reinstate once the key_id issue is resolved
|
||||
// Check the keys in the database
|
||||
keys, err := s.admin.sender.GetKeyIDsForGroup(c.ID())
|
||||
/*keys, err := s.admin.sender.GetKeyIDsForGroup(c.ID())
|
||||
s.Require().NoError(err)
|
||||
keyCount := len(keys)
|
||||
keyCount := len(keys)*/
|
||||
|
||||
// Check that rekeying is occurring by counting the number of keyIDs in the encryptor's DB
|
||||
// This test could be flaky, as the rekey function may not be finished before RekeyInterval * 2 has passed
|
||||
for i := 0; i < 5; i++ {
|
||||
/*for i := 0; i < 5; i++ {
|
||||
time.Sleep(s.admin.communitiesManager.RekeyInterval * 2)
|
||||
keys, err = s.admin.sender.GetKeyIDsForGroup(c.ID())
|
||||
s.Require().NoError(err)
|
||||
s.Require().Greater(len(keys), keyCount)
|
||||
keyCount = len(keys)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -614,10 +614,9 @@ func (s *encryptor) getNextHashRatchetKeyID(groupID []byte) (uint32, error) {
|
|||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
currentTime := (uint32)(time.Now().UnixNano() / int64(time.Millisecond))
|
||||
keyIDBump := (uint32)(10)
|
||||
currentTime := GetCurrentTime()
|
||||
if latestKeyID < currentTime {
|
||||
return currentTime + keyIDBump, nil
|
||||
return bumpKeyID(currentTime), nil
|
||||
}
|
||||
|
||||
return latestKeyID + 1, nil
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package encryption
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const keyBumpValue = uint32(10)
|
||||
|
||||
// GetCurrentTime returns the current unix time in milliseconds
|
||||
func GetCurrentTime() uint32 {
|
||||
return (uint32)(time.Now().UnixNano() / int64(time.Millisecond))
|
||||
}
|
||||
|
||||
// bumpKeyID takes a timestampID and returns its value incremented by the keyBumpValue
|
||||
func bumpKeyID(timestampID uint32) uint32 {
|
||||
return timestampID + keyBumpValue
|
||||
}
|
|
@ -2032,8 +2032,7 @@ func (m *Messenger) SendKeyExchangeMessage(communityID []byte, pubkeys []*ecdsa.
|
|||
return nil
|
||||
}
|
||||
|
||||
// RekeyCommunity takes a communities.Community and triggers a force rekey event,
|
||||
// after rekeying has be triggered updates the communities.Community rekeyed_at value to now
|
||||
// RekeyCommunity takes a communities.Community.config.ID and triggers a force rekey event for that community
|
||||
func (m *Messenger) RekeyCommunity(cID types.HexBytes) error {
|
||||
// Get the community as the member list could have changed
|
||||
c, err := m.GetCommunityByID(cID)
|
||||
|
@ -2042,13 +2041,7 @@ func (m *Messenger) RekeyCommunity(cID types.HexBytes) error {
|
|||
}
|
||||
|
||||
// RekeyCommunity
|
||||
err = m.SendKeyExchangeMessage(c.ID(), c.GetMemberPubkeys(), common.KeyExMsgRekey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update rekey timestamp
|
||||
return m.communitiesManager.SetRekeyedAtClock(c.ID(), time.Now())
|
||||
return m.SendKeyExchangeMessage(c.ID(), c.GetMemberPubkeys(), common.KeyExMsgRekey)
|
||||
}
|
||||
|
||||
func (m *Messenger) UnbanUserFromCommunity(request *requests.UnbanUserFromCommunity) (*MessengerResponse, error) {
|
||||
|
@ -4224,17 +4217,36 @@ func chunkAttachmentsByByteSize(slice []*protobuf.DiscordMessageAttachment, maxF
|
|||
return chunks
|
||||
}
|
||||
|
||||
// GetCurrentKeyForGroup returns the latest key timestampID belonging to a key group
|
||||
func (m *Messenger) GetCurrentKeyForGroup(groupID []byte) (uint32, error) {
|
||||
return m.sender.GetCurrentKeyForGroup(groupID)
|
||||
}
|
||||
|
||||
var rekeyCommunities = false
|
||||
|
||||
// startCommunityRekeyLoop creates a 5-minute ticker and starts a routine that attempts to rekey every community every tick
|
||||
func (m *Messenger) startCommunityRekeyLoop() {
|
||||
logger := m.logger.Named("CommunityRekeyLoop")
|
||||
// TODO reactivate once resolved the issue with key_id see rekeyAllCommunities() for details
|
||||
if !rekeyCommunities { // Always return
|
||||
return
|
||||
}
|
||||
|
||||
var d time.Duration
|
||||
if m.communitiesManager.RekeyInterval != 0 {
|
||||
if m.communitiesManager.RekeyInterval < 10 {
|
||||
d = time.Nanosecond
|
||||
} else {
|
||||
d = m.communitiesManager.RekeyInterval / 10
|
||||
}
|
||||
} else {
|
||||
d = 5 * time.Minute
|
||||
}
|
||||
|
||||
if d > 0 { // Always return
|
||||
return
|
||||
}
|
||||
|
||||
ticker := time.NewTicker(d)
|
||||
go func() {
|
||||
for {
|
||||
|
@ -4260,7 +4272,7 @@ func (m *Messenger) startCommunityRekeyLoop() {
|
|||
func (m *Messenger) rekeyAllCommunities(logger *zap.Logger) {
|
||||
// Determine the rekey interval, if the value is not set as a property of m.communitiesManager
|
||||
// default to one hour
|
||||
// TODO in future perhaps have a community level rki rather than a global rki
|
||||
// TODO in future have a community level rki rather than a global rki
|
||||
var rki time.Duration
|
||||
if m.communitiesManager.RekeyInterval == 0 {
|
||||
rki = time.Hour
|
||||
|
@ -4275,7 +4287,19 @@ func (m *Messenger) rekeyAllCommunities(logger *zap.Logger) {
|
|||
return
|
||||
}
|
||||
for _, c := range cs {
|
||||
if c.IsAdmin() && c.Encrypted() && c.RekeyedAt().Add(rki).Before(time.Now()) {
|
||||
keyTimestampID, err := m.GetCurrentKeyForGroup(c.ID())
|
||||
if err != nil {
|
||||
logger.Error("error getting current keyTimestampID for community", zap.Error(err), zap.Binary("community ID", c.ID()))
|
||||
continue
|
||||
}
|
||||
|
||||
// TODO add functionality to encryptor.go that compares the timestamps and returns a bool
|
||||
// c.RekeyedAt().Add(rki).Before(time.Now())
|
||||
// keyTimestampID + rki < time.Now()
|
||||
// Just using the vars that will be used later
|
||||
fmt.Printf("%d, %d", rki, keyTimestampID)
|
||||
|
||||
if c.IsControlNode() && c.Encrypted() { // && c.RekeyedAt().Add(rki).Before(time.Now())
|
||||
err := m.RekeyCommunity(c.ID())
|
||||
if err != nil {
|
||||
logger.Error("error sending rekey message", zap.Error(err), zap.Binary("community ID", c.ID()))
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
// 1683725607_mark_discord_messages_as_seen.up.sql (108B)
|
||||
// 1684174617_add_url_previews_to_user_messages.up.sql (58B)
|
||||
// 1684175608_add_token_balances.up.sql (467B)
|
||||
// 1684926535_add_rekeyed_at_column_to_communities.up.sql (88B)
|
||||
// 1684979808_sync_activity_center_notifications.up.sql (169B)
|
||||
// 1685383829_add_communities_mute_till.up.sql (69B)
|
||||
// 1685964183_add_chainids_to_revealed_addresses.up.sql (88B)
|
||||
|
@ -98,7 +97,6 @@
|
|||
// 1687416607_add_communities_check_channel_permission_responses_table.up.sql (739B)
|
||||
// 1687856939_add_community_tokens_decimals.up.sql (65B)
|
||||
// 1687959987_modify_community_tokens_supply_as_string.up.sql (77B)
|
||||
// 1687995250_add_rekeyed_at_column_to_communities.up.sql (88B)
|
||||
// 1689258900_add_airdrop_address_to_revealed_addresses.up.sql (99B)
|
||||
// 1689266326_create_communities_events_table.up.sql (164B)
|
||||
// README.md (554B)
|
||||
|
@ -1971,26 +1969,6 @@ func _1684175608_add_token_balancesUpSql() (*asset, error) {
|
|||
return a, nil
|
||||
}
|
||||
|
||||
var __1684926535_add_rekeyed_at_column_to_communitiesUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\xce\xcf\xcd\x2d\xcd\xcb\x2c\xc9\x4c\x2d\x8e\x47\x62\x2b\x38\xba\xb8\x28\x38\xfb\xfb\x84\xfa\xfa\x29\x14\xa5\x66\xa7\x56\xa6\xa6\xc4\x27\x96\x28\x84\x78\xfa\xba\x06\x87\x38\xfa\x06\x28\xb8\xb8\xba\x39\x86\xfa\x84\x28\x18\x28\xf8\xf9\x87\x28\xf8\x85\xfa\xf8\x58\x73\x01\x02\x00\x00\xff\xff\xe5\x49\x11\x67\x58\x00\x00\x00")
|
||||
|
||||
func _1684926535_add_rekeyed_at_column_to_communitiesUpSqlBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
__1684926535_add_rekeyed_at_column_to_communitiesUpSql,
|
||||
"1684926535_add_rekeyed_at_column_to_communities.up.sql",
|
||||
)
|
||||
}
|
||||
|
||||
func _1684926535_add_rekeyed_at_column_to_communitiesUpSql() (*asset, error) {
|
||||
bytes, err := _1684926535_add_rekeyed_at_column_to_communitiesUpSqlBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1684926535_add_rekeyed_at_column_to_communities.up.sql", size: 88, mode: os.FileMode(0644), modTime: time.Unix(1689803274, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x32, 0x2e, 0x1e, 0x79, 0xed, 0xf0, 0x90, 0xc1, 0x26, 0x72, 0x46, 0xcc, 0x54, 0x8a, 0x9, 0xb3, 0xe1, 0x70, 0x46, 0x13, 0x26, 0x89, 0xb5, 0xde, 0xc5, 0x74, 0xe, 0x26, 0xc2, 0x37, 0x56, 0xe8}}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var __1684979808_sync_activity_center_notificationsUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\xcc\xc1\x09\x02\x31\x10\x05\xd0\xbb\x55\xfc\x12\xbc\x7b\x8a\x26\x82\x30\x66\x41\x26\xe7\x30\x64\x23\xcc\x25\x2b\xe6\x2b\xd8\xbd\x1d\x08\x36\xf0\x82\x68\xba\x41\xc3\x51\x12\xac\xd1\xdf\xce\x4f\x6d\x7d\xb0\x3f\xeb\xa4\xb1\x4f\x84\x18\x71\x5a\xa4\x5c\x33\x5e\x8f\xd5\xd8\xd7\x6a\xc4\x25\x2b\xf2\xa2\xc8\x45\x04\x31\x9d\x43\x11\xc5\xfe\xb0\xfb\x05\x8e\x8d\x7e\xf7\x66\xf4\x6d\xfc\xeb\x7e\x03\x00\x00\xff\xff\x09\xb8\x1a\x7c\xa9\x00\x00\x00")
|
||||
|
||||
func _1684979808_sync_activity_center_notificationsUpSqlBytes() ([]byte, error) {
|
||||
|
@ -2131,26 +2109,6 @@ func _1687959987_modify_community_tokens_supply_as_stringUpSql() (*asset, error)
|
|||
return a, nil
|
||||
}
|
||||
|
||||
var __1687995250_add_rekeyed_at_column_to_communitiesUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\xce\xcf\xcd\x2d\xcd\xcb\x2c\xc9\x4c\x2d\x8e\x47\x62\x2b\x38\xba\xb8\x28\x38\xfb\xfb\x84\xfa\xfa\x29\x14\xa5\x66\xa7\x56\xa6\xa6\xc4\x27\x96\x28\x84\x78\xfa\xba\x06\x87\x38\xfa\x06\x28\xb8\xb8\xba\x39\x86\xfa\x84\x28\x18\x28\xf8\xf9\x87\x28\xf8\x85\xfa\xf8\x58\x73\x01\x02\x00\x00\xff\xff\xe5\x49\x11\x67\x58\x00\x00\x00")
|
||||
|
||||
func _1687995250_add_rekeyed_at_column_to_communitiesUpSqlBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
__1687995250_add_rekeyed_at_column_to_communitiesUpSql,
|
||||
"1687995250_add_rekeyed_at_column_to_communities.up.sql",
|
||||
)
|
||||
}
|
||||
|
||||
func _1687995250_add_rekeyed_at_column_to_communitiesUpSql() (*asset, error) {
|
||||
bytes, err := _1687995250_add_rekeyed_at_column_to_communitiesUpSqlBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "1687995250_add_rekeyed_at_column_to_communities.up.sql", size: 88, mode: os.FileMode(0644), modTime: time.Unix(1689803274, 0)}
|
||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x32, 0x2e, 0x1e, 0x79, 0xed, 0xf0, 0x90, 0xc1, 0x26, 0x72, 0x46, 0xcc, 0x54, 0x8a, 0x9, 0xb3, 0xe1, 0x70, 0x46, 0x13, 0x26, 0x89, 0xb5, 0xde, 0xc5, 0x74, 0xe, 0x26, 0xc2, 0x37, 0x56, 0xe8}}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var __1689258900_add_airdrop_address_to_revealed_addressesUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x34\xc9\x31\x0e\xc2\x30\x0c\x05\xd0\x9d\x53\xf8\x1e\x4c\x29\xcd\x66\x1a\x09\x95\xd9\x8a\xf0\x1f\x8c\x68\x0d\x76\xca\xf9\x99\x98\x5f\xe1\xb5\xde\x68\x2d\x13\x57\x7a\xf8\xb6\x1d\xbb\x0d\x43\x4a\xe0\x73\x20\x47\xca\x70\x79\xba\xed\x12\xf8\xa2\xbf\xa0\xd2\x55\x03\x99\x48\x2a\xf3\x4c\x97\xc6\xf7\xeb\x42\x96\xd2\x2d\x34\xfc\xfd\x77\x9a\x5a\xe3\x5a\x96\xf3\xe9\x17\x00\x00\xff\xff\xa2\x39\x8f\xf1\x63\x00\x00\x00")
|
||||
|
||||
func _1689258900_add_airdrop_address_to_revealed_addressesUpSqlBytes() ([]byte, error) {
|
||||
|
@ -2502,8 +2460,6 @@ var _bindata = map[string]func() (*asset, error){
|
|||
|
||||
"1684175608_add_token_balances.up.sql": _1684175608_add_token_balancesUpSql,
|
||||
|
||||
"1684926535_add_rekeyed_at_column_to_communities.up.sql": _1684926535_add_rekeyed_at_column_to_communitiesUpSql,
|
||||
|
||||
"1684979808_sync_activity_center_notifications.up.sql": _1684979808_sync_activity_center_notificationsUpSql,
|
||||
|
||||
"1685383829_add_communities_mute_till.up.sql": _1685383829_add_communities_mute_tillUpSql,
|
||||
|
@ -2518,8 +2474,6 @@ var _bindata = map[string]func() (*asset, error){
|
|||
|
||||
"1687959987_modify_community_tokens_supply_as_string.up.sql": _1687959987_modify_community_tokens_supply_as_stringUpSql,
|
||||
|
||||
"1687995250_add_rekeyed_at_column_to_communities.up.sql": _1687995250_add_rekeyed_at_column_to_communitiesUpSql,
|
||||
|
||||
"1689258900_add_airdrop_address_to_revealed_addresses.up.sql": _1689258900_add_airdrop_address_to_revealed_addressesUpSql,
|
||||
|
||||
"1689266326_create_communities_events_table.up.sql": _1689266326_create_communities_events_tableUpSql,
|
||||
|
@ -2660,7 +2614,6 @@ var _bintree = &bintree{nil, map[string]*bintree{
|
|||
"1683725607_mark_discord_messages_as_seen.up.sql": &bintree{_1683725607_mark_discord_messages_as_seenUpSql, map[string]*bintree{}},
|
||||
"1684174617_add_url_previews_to_user_messages.up.sql": &bintree{_1684174617_add_url_previews_to_user_messagesUpSql, map[string]*bintree{}},
|
||||
"1684175608_add_token_balances.up.sql": &bintree{_1684175608_add_token_balancesUpSql, map[string]*bintree{}},
|
||||
"1684926535_add_rekeyed_at_column_to_communities.up.sql": &bintree{_1684926535_add_rekeyed_at_column_to_communitiesUpSql, map[string]*bintree{}},
|
||||
"1684979808_sync_activity_center_notifications.up.sql": &bintree{_1684979808_sync_activity_center_notificationsUpSql, map[string]*bintree{}},
|
||||
"1685383829_add_communities_mute_till.up.sql": &bintree{_1685383829_add_communities_mute_tillUpSql, map[string]*bintree{}},
|
||||
"1685964183_add_chainids_to_revealed_addresses.up.sql": &bintree{_1685964183_add_chainids_to_revealed_addressesUpSql, map[string]*bintree{}},
|
||||
|
@ -2668,7 +2621,6 @@ var _bintree = &bintree{nil, map[string]*bintree{
|
|||
"1687416607_add_communities_check_channel_permission_responses_table.up.sql": &bintree{_1687416607_add_communities_check_channel_permission_responses_tableUpSql, map[string]*bintree{}},
|
||||
"1687856939_add_community_tokens_decimals.up.sql": &bintree{_1687856939_add_community_tokens_decimalsUpSql, map[string]*bintree{}},
|
||||
"1687959987_modify_community_tokens_supply_as_string.up.sql": &bintree{_1687959987_modify_community_tokens_supply_as_stringUpSql, map[string]*bintree{}},
|
||||
"1687995250_add_rekeyed_at_column_to_communities.up.sql": &bintree{_1687995250_add_rekeyed_at_column_to_communitiesUpSql, map[string]*bintree{}},
|
||||
"1689258900_add_airdrop_address_to_revealed_addresses.up.sql": &bintree{_1689258900_add_airdrop_address_to_revealed_addressesUpSql, map[string]*bintree{}},
|
||||
"1689266326_create_communities_events_table.up.sql": &bintree{_1689266326_create_communities_events_tableUpSql, map[string]*bintree{}},
|
||||
"README.md": &bintree{readmeMd, map[string]*bintree{}},
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE communities_communities ADD COLUMN rekeyed_at TIMESTAMP DEFAULT 0 NOT NULL;
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE communities_communities ADD COLUMN rekeyed_at TIMESTAMP DEFAULT 0 NOT NULL;
|
Loading…
Reference in New Issue