status-go/protocol/messenger_config.go

358 lines
9.6 KiB
Go
Raw Normal View History

2020-07-03 10:08:47 +00:00
package protocol
import (
"database/sql"
2021-02-17 23:14:48 +00:00
"encoding/json"
2020-07-22 07:41:40 +00:00
"github.com/status-im/status-go/rpc"
"github.com/status-im/status-go/server"
2022-01-17 03:42:11 +00:00
"github.com/status-im/status-go/services/browsers"
"github.com/status-im/status-go/services/communitytokens"
"github.com/status-im/status-go/wakuv2"
2022-01-17 03:42:11 +00:00
2020-07-22 07:41:40 +00:00
"go.uber.org/zap"
"github.com/status-im/status-go/appdatabase/migrations"
2020-11-24 23:16:19 +00:00
"github.com/status-im/status-go/multiaccounts"
2021-02-17 23:14:48 +00:00
"github.com/status-im/status-go/multiaccounts/accounts"
Sync Settings (#2478) * Sync Settings * Added valueHandlers and Database singleton Some issues remain, need a way to comparing incoming sql.DB to check if the connection is to a different file or not. Maybe make singleton instance per filename * Added functionality to check the sqlite filename * Refactor of Database.SaveSyncSettings to be used as a handler * Implemented inteface for setting sync protobuf factories * Refactored and completed adhoc send setting sync * Tidying up * Immutability refactor * Refactor settings into dedicated package * Breakout structs * Tidy up * Refactor of bulk settings sync * Bug fixes * Addressing feedback * Fix code dropped during rebase * Fix for db closed * Fix for node config related crashes * Provisional fix for type assertion - issue 2 * Adding robust type assertion checks * Partial fix for null literal db storage and json encoding * Fix for passively handling nil sql.DB, and checking if elem has len and if len is 0 * Added test for preferred name behaviour * Adding saved sync settings to MessengerResponse * Completed granular initial sync and clock from network on save * add Settings to isEmpty * Refactor of protobufs, partially done * Added syncSetting receiver handling, some bug fixes * Fix for sticker packs * Implement inactive flag on sync protobuf factory * Refactor of types and structs * Added SettingField.CanSync functionality * Addressing rebase artifact * Refactor of Setting SELECT queries * Refactor of string return queries * VERSION bump and migration index bump * Deactiveate Sync Settings * Deactiveated preferred_name and send_status_updates Co-authored-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2022-03-23 18:47:00 +00:00
"github.com/status-im/status-go/multiaccounts/settings"
2021-02-17 23:14:48 +00:00
"github.com/status-im/status-go/params"
Anon Metrics Broadcast (#2198) * Protobufs and adapters * Added basic anon metric service and config init * Added fibonacci interval incrementer * Added basic Client.Start func and integrated interval incrementer * Added new processed field to app metrics table * Added id column to app metrics table * Added migration clean up * Added appmetrics GetUnprocessed and SetToProcessedByIDs and tests There was a wierd bug where metrics in the db that did not explicitly insert a value would be NULL, so could not be found by . In addition I've added a new primary id field to the app_metrics table so that updates could be done against very specific metric rows. * Updated adaptors and db to handle proto_id I need a way to distinguish individual metric items from each other so that I can ignore the ones that have been seen before. * Moved incrementer into dedicated file * Resolve incrementer test fail * Finalised the main loop functionality * Implemented delete loop framework * Updated adaptors file name * Added delete loop delay and quit, and tweak on RawMessage gen * Completed delete loop logic * Added DBLock to prevent deletion during mainLoop * Added postgres DB connection, integrated into anonmetrics.Server * Removed proto_id from SQL migration and model * Integrated postgres with Server and updated adaptors * Function name update * Added sample config files for client and server * Fixes and testing for low level e2e * make generate * Fix lint * Fix for receiving an anonMetricBatch not in server mode * Postgres test fixes * Tidy up, make vendor and make generate * delinting * Fixing database tests * Attempted fix of does: cannot open `does' (No such file or directory) not: cannot open `not' (No such file or directory) exist: cannot open `exist' (No such file or directory) error on sql resource loas * Moved all anon metric postgres migration logic and sources into a the protocol/anonmetrics package or sub packages. I don't know if this will fix the does: cannot open `does' (No such file or directory) not: cannot open `not' (No such file or directory) exist: cannot open `exist' (No such file or directory) error that happens in Jenkins but this could work * Lint for the lint god * Why doesn't the linter list all its problems at once? * test tweaks * Fix for wakuV2 change * DB reset change * Fix for postgres db migrations fails * More robust implementation of postgres test setup and teardown * Added block for anon metrics functionality * Version Bump to 0.84.0 * Added test to check anon metrics broadcast is deactivated * Protobufs and adapters * Added basic anon metric service and config init * Added new processed field to app metrics table * Added id column to app metrics table * Added migration clean up * Added appmetrics GetUnprocessed and SetToProcessedByIDs and tests There was a wierd bug where metrics in the db that did not explicitly insert a value would be NULL, so could not be found by . In addition I've added a new primary id field to the app_metrics table so that updates could be done against very specific metric rows. * Updated adaptors and db to handle proto_id I need a way to distinguish individual metric items from each other so that I can ignore the ones that have been seen before. * Added postgres DB connection, integrated into anonmetrics.Server * Removed proto_id from SQL migration and model * Integrated postgres with Server and updated adaptors * Added sample config files for client and server * Fix lint * Fix for receiving an anonMetricBatch not in server mode * Postgres test fixes * Tidy up, make vendor and make generate * Moved all anon metric postgres migration logic and sources into a the protocol/anonmetrics package or sub packages. I don't know if this will fix the does: cannot open `does' (No such file or directory) not: cannot open `not' (No such file or directory) exist: cannot open `exist' (No such file or directory) error that happens in Jenkins but this could work
2021-09-01 12:02:18 +00:00
"github.com/status-im/status-go/protocol/anonmetrics"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/communities"
feat: introduce messenger APIs to extract discord channels As part of the new Discord <-> Status Community Import functionality, we're adding an API that extracts all discord categories and channels from a previously exported discord export file. These APIs can be used in clients to show the user what categories and channels will be imported later on. There are two APIs: 1. `Messenger.ExtractDiscordCategoriesAndChannels(filesToimport []string) (*MessengerResponse, map[string]*discord.ImportError)` This takes a list of exported discord export (JSON) files (typically one per channel), reads them, and extracts the categories and channels into dedicated data structures (`[]DiscordChannel` and `[]DiscordCategory`) It also returns the oldest message timestamp found in all extracted channels. The API is synchronous and returns the extracted data as a `*MessengerResponse`. This allows to make the API available status-go's RPC interface. The error case is a `map[string]*discord.ImportError` where each key is a file path of a JSON file that we tried to extract data from, and the value a `discord.ImportError` which holds an error message and an error code, allowing for distinguishing between "critical" errors and "non-critical" errors. 2. `Messenger.RequestExtractDiscordCategoriesAndChannels(filesToImport []string)` This is the asynchronous counterpart to `ExtractDiscordCategoriesAndChannels`. The reason this API has been added is because discord servers can have a lot of message and channel data, which causes `ExtractDiscordCategoriesAndChannels` to block the thread for too long, making apps potentially feel like they are stuck. This API runs inside a go routine, eventually calls `ExtractDiscordCategoriesAndChannels`, and then emits a newly introduced `DiscordCategoriesAndChannelsExtractedSignal` that clients can react to. Failure of extraction has to be determined by the `discord.ImportErrors` emitted by the signal. **A note about exported discord history files** We expect users to export their discord histories via the [DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter/wiki/GUI%2C-CLI-and-Formats-explained#exportguild) tool. The tool allows to export the data in different formats, such as JSON, HTML and CSV. We expect users to have their data exported as JSON. Closes: https://github.com/status-im/status-desktop/issues/6690
2022-07-13 09:33:53 +00:00
"github.com/status-im/status-go/protocol/discord"
2020-07-03 10:08:47 +00:00
"github.com/status-im/status-go/protocol/protobuf"
2020-07-22 07:41:40 +00:00
"github.com/status-im/status-go/protocol/pushnotificationclient"
"github.com/status-im/status-go/protocol/pushnotificationserver"
2020-07-03 10:08:47 +00:00
"github.com/status-im/status-go/protocol/transport"
"github.com/status-im/status-go/protocol/wakusync"
"github.com/status-im/status-go/services/mailservers"
"github.com/status-im/status-go/services/wallet"
2020-07-03 10:08:47 +00:00
)
2021-02-23 15:47:45 +00:00
type MessageDeliveredHandler func(string, string)
type MessengerSignalsHandler interface {
MessageDelivered(chatID string, messageID string)
CommunityInfoFound(community *communities.Community)
2021-03-25 15:15:22 +00:00
MessengerResponse(response *MessengerResponse)
HistoryRequestStarted(numBatches int)
HistoryRequestCompleted()
BackupPerformed(uint64)
HistoryArchivesProtocolEnabled()
HistoryArchivesProtocolDisabled()
CreatingHistoryArchives(communityID string)
NoHistoryArchivesCreated(communityID string, from int, to int)
HistoryArchivesCreated(communityID string, from int, to int)
HistoryArchivesSeeding(communityID string)
HistoryArchivesUnseeded(communityID string)
HistoryArchiveDownloaded(communityID string, from int, to int)
DownloadingHistoryArchivesStarted(communityID string)
DownloadingHistoryArchivesFinished(communityID string)
ImportingHistoryArchiveMessages(communityID string)
StatusUpdatesTimedOut(statusUpdates *[]UserStatus)
feat: introduce messenger APIs to extract discord channels As part of the new Discord <-> Status Community Import functionality, we're adding an API that extracts all discord categories and channels from a previously exported discord export file. These APIs can be used in clients to show the user what categories and channels will be imported later on. There are two APIs: 1. `Messenger.ExtractDiscordCategoriesAndChannels(filesToimport []string) (*MessengerResponse, map[string]*discord.ImportError)` This takes a list of exported discord export (JSON) files (typically one per channel), reads them, and extracts the categories and channels into dedicated data structures (`[]DiscordChannel` and `[]DiscordCategory`) It also returns the oldest message timestamp found in all extracted channels. The API is synchronous and returns the extracted data as a `*MessengerResponse`. This allows to make the API available status-go's RPC interface. The error case is a `map[string]*discord.ImportError` where each key is a file path of a JSON file that we tried to extract data from, and the value a `discord.ImportError` which holds an error message and an error code, allowing for distinguishing between "critical" errors and "non-critical" errors. 2. `Messenger.RequestExtractDiscordCategoriesAndChannels(filesToImport []string)` This is the asynchronous counterpart to `ExtractDiscordCategoriesAndChannels`. The reason this API has been added is because discord servers can have a lot of message and channel data, which causes `ExtractDiscordCategoriesAndChannels` to block the thread for too long, making apps potentially feel like they are stuck. This API runs inside a go routine, eventually calls `ExtractDiscordCategoriesAndChannels`, and then emits a newly introduced `DiscordCategoriesAndChannelsExtractedSignal` that clients can react to. Failure of extraction has to be determined by the `discord.ImportErrors` emitted by the signal. **A note about exported discord history files** We expect users to export their discord histories via the [DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter/wiki/GUI%2C-CLI-and-Formats-explained#exportguild) tool. The tool allows to export the data in different formats, such as JSON, HTML and CSV. We expect users to have their data exported as JSON. Closes: https://github.com/status-im/status-desktop/issues/6690
2022-07-13 09:33:53 +00:00
DiscordCategoriesAndChannelsExtracted(categories []*discord.Category, channels []*discord.Channel, oldestMessageTimestamp int64, errors map[string]*discord.ImportError)
2022-09-29 11:50:23 +00:00
DiscordCommunityImportProgress(importProgress *discord.ImportProgress)
DiscordCommunityImportFinished(communityID string)
DiscordCommunityImportCancelled(communityID string)
DiscordChannelImportProgress(importProgress *discord.ImportProgress)
DiscordChannelImportFinished(communityID string, channelID string)
DiscordChannelImportCancelled(channelID string)
SendWakuFetchingBackupProgress(response *wakusync.WakuBackedUpDataResponse)
SendWakuBackedUpProfile(response *wakusync.WakuBackedUpDataResponse)
SendWakuBackedUpSettings(response *wakusync.WakuBackedUpDataResponse)
SendWakuBackedUpKeypair(response *wakusync.WakuBackedUpDataResponse)
SendWakuBackedUpWatchOnlyAccount(response *wakusync.WakuBackedUpDataResponse)
SendCuratedCommunitiesUpdate(response *communities.KnownCommunitiesResponse)
}
2020-07-03 10:08:47 +00:00
type config struct {
// systemMessagesTranslations holds translations for system-messages
2021-03-29 15:41:30 +00:00
systemMessagesTranslations *systemMessageTranslationsMap
2020-07-03 10:08:47 +00:00
// Config for the envelopes monitor
envelopesMonitorConfig *transport.EnvelopesMonitorConfig
featureFlags common.FeatureFlags
2020-07-03 10:08:47 +00:00
appDb *sql.DB
walletDb *sql.DB
afterDbCreatedHooks []Option
multiAccount *multiaccounts.Database
mailserversDatabase *mailservers.Database
account *multiaccounts.Account
clusterConfig params.ClusterConfig
browserDatabase *browsers.Database
torrentConfig *params.TorrentConfig
walletConfig *params.WalletConfig
walletService *wallet.Service
communityTokensService communitytokens.ServiceInterface
httpServer *server.MediaServer
rpcClient *rpc.Client
tokenManager communities.TokenManager
2020-07-03 10:08:47 +00:00
2021-01-11 10:32:51 +00:00
verifyTransactionClient EthClient
verifyENSURL string
verifyENSContractAddress string
2020-07-03 10:08:47 +00:00
Anon Metrics Broadcast (#2198) * Protobufs and adapters * Added basic anon metric service and config init * Added fibonacci interval incrementer * Added basic Client.Start func and integrated interval incrementer * Added new processed field to app metrics table * Added id column to app metrics table * Added migration clean up * Added appmetrics GetUnprocessed and SetToProcessedByIDs and tests There was a wierd bug where metrics in the db that did not explicitly insert a value would be NULL, so could not be found by . In addition I've added a new primary id field to the app_metrics table so that updates could be done against very specific metric rows. * Updated adaptors and db to handle proto_id I need a way to distinguish individual metric items from each other so that I can ignore the ones that have been seen before. * Moved incrementer into dedicated file * Resolve incrementer test fail * Finalised the main loop functionality * Implemented delete loop framework * Updated adaptors file name * Added delete loop delay and quit, and tweak on RawMessage gen * Completed delete loop logic * Added DBLock to prevent deletion during mainLoop * Added postgres DB connection, integrated into anonmetrics.Server * Removed proto_id from SQL migration and model * Integrated postgres with Server and updated adaptors * Function name update * Added sample config files for client and server * Fixes and testing for low level e2e * make generate * Fix lint * Fix for receiving an anonMetricBatch not in server mode * Postgres test fixes * Tidy up, make vendor and make generate * delinting * Fixing database tests * Attempted fix of does: cannot open `does' (No such file or directory) not: cannot open `not' (No such file or directory) exist: cannot open `exist' (No such file or directory) error on sql resource loas * Moved all anon metric postgres migration logic and sources into a the protocol/anonmetrics package or sub packages. I don't know if this will fix the does: cannot open `does' (No such file or directory) not: cannot open `not' (No such file or directory) exist: cannot open `exist' (No such file or directory) error that happens in Jenkins but this could work * Lint for the lint god * Why doesn't the linter list all its problems at once? * test tweaks * Fix for wakuV2 change * DB reset change * Fix for postgres db migrations fails * More robust implementation of postgres test setup and teardown * Added block for anon metrics functionality * Version Bump to 0.84.0 * Added test to check anon metrics broadcast is deactivated * Protobufs and adapters * Added basic anon metric service and config init * Added new processed field to app metrics table * Added id column to app metrics table * Added migration clean up * Added appmetrics GetUnprocessed and SetToProcessedByIDs and tests There was a wierd bug where metrics in the db that did not explicitly insert a value would be NULL, so could not be found by . In addition I've added a new primary id field to the app_metrics table so that updates could be done against very specific metric rows. * Updated adaptors and db to handle proto_id I need a way to distinguish individual metric items from each other so that I can ignore the ones that have been seen before. * Added postgres DB connection, integrated into anonmetrics.Server * Removed proto_id from SQL migration and model * Integrated postgres with Server and updated adaptors * Added sample config files for client and server * Fix lint * Fix for receiving an anonMetricBatch not in server mode * Postgres test fixes * Tidy up, make vendor and make generate * Moved all anon metric postgres migration logic and sources into a the protocol/anonmetrics package or sub packages. I don't know if this will fix the does: cannot open `does' (No such file or directory) not: cannot open `not' (No such file or directory) exist: cannot open `exist' (No such file or directory) error that happens in Jenkins but this could work
2021-09-01 12:02:18 +00:00
anonMetricsClientConfig *anonmetrics.ClientConfig
anonMetricsServerConfig *anonmetrics.ServerConfig
2020-07-22 07:41:40 +00:00
pushNotificationServerConfig *pushnotificationserver.Config
pushNotificationClientConfig *pushnotificationclient.Config
2020-07-03 10:08:47 +00:00
logger *zap.Logger
2021-02-23 15:47:45 +00:00
outputMessagesCSV bool
messengerSignalsHandler MessengerSignalsHandler
telemetryServerURL string
wakuService *wakuv2.Waku
2020-07-03 10:08:47 +00:00
}
type Option func(*config) error
// WithSystemMessagesTranslations is required for Group Chats which are currently disabled.
// nolint: unused
func WithSystemMessagesTranslations(t map[protobuf.MembershipUpdateEvent_EventType]string) Option {
return func(c *config) error {
2021-03-29 15:41:30 +00:00
c.systemMessagesTranslations.Init(t)
2020-07-03 10:08:47 +00:00
return nil
}
}
func WithCustomLogger(logger *zap.Logger) Option {
return func(c *config) error {
c.logger = logger
return nil
}
}
func WithVerifyTransactionClient(client EthClient) Option {
2020-07-03 10:08:47 +00:00
return func(c *config) error {
c.verifyTransactionClient = client
2020-07-03 10:08:47 +00:00
return nil
}
}
func WithDatabase(db *sql.DB) Option {
2020-07-03 10:08:47 +00:00
return func(c *config) error {
c.appDb = db
2020-07-03 10:08:47 +00:00
return nil
}
}
func WithWalletDatabase(db *sql.DB) Option {
2020-07-03 10:08:47 +00:00
return func(c *config) error {
c.walletDb = db
2020-07-03 10:08:47 +00:00
return nil
}
}
func WithToplevelDatabaseMigrations() Option {
return func(c *config) error {
c.afterDbCreatedHooks = append(c.afterDbCreatedHooks, func(c *config) error {
return migrations.Migrate(c.appDb, nil)
})
return nil
}
}
Sync Settings (#2478) * Sync Settings * Added valueHandlers and Database singleton Some issues remain, need a way to comparing incoming sql.DB to check if the connection is to a different file or not. Maybe make singleton instance per filename * Added functionality to check the sqlite filename * Refactor of Database.SaveSyncSettings to be used as a handler * Implemented inteface for setting sync protobuf factories * Refactored and completed adhoc send setting sync * Tidying up * Immutability refactor * Refactor settings into dedicated package * Breakout structs * Tidy up * Refactor of bulk settings sync * Bug fixes * Addressing feedback * Fix code dropped during rebase * Fix for db closed * Fix for node config related crashes * Provisional fix for type assertion - issue 2 * Adding robust type assertion checks * Partial fix for null literal db storage and json encoding * Fix for passively handling nil sql.DB, and checking if elem has len and if len is 0 * Added test for preferred name behaviour * Adding saved sync settings to MessengerResponse * Completed granular initial sync and clock from network on save * add Settings to isEmpty * Refactor of protobufs, partially done * Added syncSetting receiver handling, some bug fixes * Fix for sticker packs * Implement inactive flag on sync protobuf factory * Refactor of types and structs * Added SettingField.CanSync functionality * Addressing rebase artifact * Refactor of Setting SELECT queries * Refactor of string return queries * VERSION bump and migration index bump * Deactiveate Sync Settings * Deactiveated preferred_name and send_status_updates Co-authored-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2022-03-23 18:47:00 +00:00
func WithAppSettings(s settings.Settings, nc params.NodeConfig) Option {
2021-02-17 23:14:48 +00:00
return func(c *config) error {
c.afterDbCreatedHooks = append(c.afterDbCreatedHooks, func(c *config) error {
if s.Networks == nil {
networks := new(json.RawMessage)
if err := networks.UnmarshalJSON([]byte("net")); err != nil {
return err
}
s.Networks = networks
}
sDB, err := accounts.NewDB(c.appDb)
Sync Settings (#2478) * Sync Settings * Added valueHandlers and Database singleton Some issues remain, need a way to comparing incoming sql.DB to check if the connection is to a different file or not. Maybe make singleton instance per filename * Added functionality to check the sqlite filename * Refactor of Database.SaveSyncSettings to be used as a handler * Implemented inteface for setting sync protobuf factories * Refactored and completed adhoc send setting sync * Tidying up * Immutability refactor * Refactor settings into dedicated package * Breakout structs * Tidy up * Refactor of bulk settings sync * Bug fixes * Addressing feedback * Fix code dropped during rebase * Fix for db closed * Fix for node config related crashes * Provisional fix for type assertion - issue 2 * Adding robust type assertion checks * Partial fix for null literal db storage and json encoding * Fix for passively handling nil sql.DB, and checking if elem has len and if len is 0 * Added test for preferred name behaviour * Adding saved sync settings to MessengerResponse * Completed granular initial sync and clock from network on save * add Settings to isEmpty * Refactor of protobufs, partially done * Added syncSetting receiver handling, some bug fixes * Fix for sticker packs * Implement inactive flag on sync protobuf factory * Refactor of types and structs * Added SettingField.CanSync functionality * Addressing rebase artifact * Refactor of Setting SELECT queries * Refactor of string return queries * VERSION bump and migration index bump * Deactiveate Sync Settings * Deactiveated preferred_name and send_status_updates Co-authored-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2022-03-23 18:47:00 +00:00
if err != nil {
return err
}
2021-02-17 23:14:48 +00:00
return sDB.CreateSettings(s, nc)
})
return nil
}
}
func WithMultiAccounts(ma *multiaccounts.Database) Option {
return func(c *config) error {
c.multiAccount = ma
return nil
}
}
func WithMailserversDatabase(ma *mailservers.Database) Option {
return func(c *config) error {
c.mailserversDatabase = ma
return nil
}
}
2020-12-09 14:03:43 +00:00
func WithAccount(acc *multiaccounts.Account) Option {
return func(c *config) error {
c.account = acc
return nil
}
}
2022-01-17 03:42:11 +00:00
func WithBrowserDatabase(bd *browsers.Database) Option {
return func(c *config) error {
c.browserDatabase = bd
if c.browserDatabase == nil {
c.afterDbCreatedHooks = append(c.afterDbCreatedHooks, func(c *config) error {
c.browserDatabase = browsers.NewDB(c.appDb)
2022-01-17 03:42:11 +00:00
return nil
})
}
return nil
}
}
Anon Metrics Broadcast (#2198) * Protobufs and adapters * Added basic anon metric service and config init * Added fibonacci interval incrementer * Added basic Client.Start func and integrated interval incrementer * Added new processed field to app metrics table * Added id column to app metrics table * Added migration clean up * Added appmetrics GetUnprocessed and SetToProcessedByIDs and tests There was a wierd bug where metrics in the db that did not explicitly insert a value would be NULL, so could not be found by . In addition I've added a new primary id field to the app_metrics table so that updates could be done against very specific metric rows. * Updated adaptors and db to handle proto_id I need a way to distinguish individual metric items from each other so that I can ignore the ones that have been seen before. * Moved incrementer into dedicated file * Resolve incrementer test fail * Finalised the main loop functionality * Implemented delete loop framework * Updated adaptors file name * Added delete loop delay and quit, and tweak on RawMessage gen * Completed delete loop logic * Added DBLock to prevent deletion during mainLoop * Added postgres DB connection, integrated into anonmetrics.Server * Removed proto_id from SQL migration and model * Integrated postgres with Server and updated adaptors * Function name update * Added sample config files for client and server * Fixes and testing for low level e2e * make generate * Fix lint * Fix for receiving an anonMetricBatch not in server mode * Postgres test fixes * Tidy up, make vendor and make generate * delinting * Fixing database tests * Attempted fix of does: cannot open `does' (No such file or directory) not: cannot open `not' (No such file or directory) exist: cannot open `exist' (No such file or directory) error on sql resource loas * Moved all anon metric postgres migration logic and sources into a the protocol/anonmetrics package or sub packages. I don't know if this will fix the does: cannot open `does' (No such file or directory) not: cannot open `not' (No such file or directory) exist: cannot open `exist' (No such file or directory) error that happens in Jenkins but this could work * Lint for the lint god * Why doesn't the linter list all its problems at once? * test tweaks * Fix for wakuV2 change * DB reset change * Fix for postgres db migrations fails * More robust implementation of postgres test setup and teardown * Added block for anon metrics functionality * Version Bump to 0.84.0 * Added test to check anon metrics broadcast is deactivated * Protobufs and adapters * Added basic anon metric service and config init * Added new processed field to app metrics table * Added id column to app metrics table * Added migration clean up * Added appmetrics GetUnprocessed and SetToProcessedByIDs and tests There was a wierd bug where metrics in the db that did not explicitly insert a value would be NULL, so could not be found by . In addition I've added a new primary id field to the app_metrics table so that updates could be done against very specific metric rows. * Updated adaptors and db to handle proto_id I need a way to distinguish individual metric items from each other so that I can ignore the ones that have been seen before. * Added postgres DB connection, integrated into anonmetrics.Server * Removed proto_id from SQL migration and model * Integrated postgres with Server and updated adaptors * Added sample config files for client and server * Fix lint * Fix for receiving an anonMetricBatch not in server mode * Postgres test fixes * Tidy up, make vendor and make generate * Moved all anon metric postgres migration logic and sources into a the protocol/anonmetrics package or sub packages. I don't know if this will fix the does: cannot open `does' (No such file or directory) not: cannot open `not' (No such file or directory) exist: cannot open `exist' (No such file or directory) error that happens in Jenkins but this could work
2021-09-01 12:02:18 +00:00
func WithAnonMetricsClientConfig(anonMetricsClientConfig *anonmetrics.ClientConfig) Option {
return func(c *config) error {
c.anonMetricsClientConfig = anonMetricsClientConfig
return nil
}
}
func WithAnonMetricsServerConfig(anonMetricsServerConfig *anonmetrics.ServerConfig) Option {
return func(c *config) error {
c.anonMetricsServerConfig = anonMetricsServerConfig
return nil
}
}
func WithTelemetry(serverURL string) Option {
return func(c *config) error {
c.telemetryServerURL = serverURL
return nil
}
}
2020-07-22 07:41:40 +00:00
func WithPushNotificationServerConfig(pushNotificationServerConfig *pushnotificationserver.Config) Option {
2020-07-03 10:08:47 +00:00
return func(c *config) error {
c.pushNotificationServerConfig = pushNotificationServerConfig
return nil
}
}
2020-07-22 07:41:40 +00:00
func WithPushNotificationClientConfig(pushNotificationClientConfig *pushnotificationclient.Config) Option {
2020-07-15 12:25:01 +00:00
return func(c *config) error {
c.pushNotificationClientConfig = pushNotificationClientConfig
return nil
}
}
2020-07-03 10:08:47 +00:00
func WithDatasync() func(c *config) error {
return func(c *config) error {
c.featureFlags.Datasync = true
2020-07-03 10:08:47 +00:00
return nil
}
}
func WithPushNotifications() func(c *config) error {
return func(c *config) error {
c.featureFlags.PushNotifications = true
return nil
}
}
2020-07-03 10:08:47 +00:00
func WithEnvelopesMonitorConfig(emc *transport.EnvelopesMonitorConfig) Option {
return func(c *config) error {
c.envelopesMonitorConfig = emc
return nil
}
}
2021-02-23 15:47:45 +00:00
func WithSignalsHandler(h MessengerSignalsHandler) Option {
2021-02-23 15:47:45 +00:00
return func(c *config) error {
c.messengerSignalsHandler = h
2021-02-23 15:47:45 +00:00
return nil
}
}
2021-01-11 10:32:51 +00:00
func WithENSVerificationConfig(url, address string) Option {
2021-01-11 10:32:51 +00:00
return func(c *config) error {
c.verifyENSURL = url
c.verifyENSContractAddress = address
return nil
}
}
2022-01-12 16:02:01 +00:00
func WithClusterConfig(cc params.ClusterConfig) Option {
return func(c *config) error {
c.clusterConfig = cc
return nil
}
}
func WithTorrentConfig(tc *params.TorrentConfig) Option {
return func(c *config) error {
c.torrentConfig = tc
return nil
}
}
func WithHTTPServer(s *server.MediaServer) Option {
return func(c *config) error {
c.httpServer = s
return nil
}
}
func WithRPCClient(r *rpc.Client) Option {
return func(c *config) error {
c.rpcClient = r
return nil
}
}
func WithWalletConfig(wc *params.WalletConfig) Option {
return func(c *config) error {
c.walletConfig = wc
return nil
}
}
func WithMessageCSV(enabled bool) Option {
return func(c *config) error {
c.outputMessagesCSV = enabled
return nil
}
}
func WithWalletService(s *wallet.Service) Option {
return func(c *config) error {
c.walletService = s
return nil
}
}
func WithCommunityTokensService(s communitytokens.ServiceInterface) Option {
return func(c *config) error {
c.communityTokensService = s
return nil
}
}
func WithWakuService(s *wakuv2.Waku) Option {
return func(c *config) error {
c.wakuService = s
return nil
}
}
func WithTokenManager(tokenManager communities.TokenManager) Option {
return func(c *config) error {
c.tokenManager = tokenManager
return nil
}
}