Compare commits
11 commits
call-signa
...
main
Author | SHA1 | Date | |
---|---|---|---|
d983bfb9a3 | |||
097e95bdb1 | |||
fc7a556b5d | |||
10dab5a5c9 | |||
|
3e33f0a3f7 | ||
|
5470eb90d9 | ||
|
1ced8e01b2 | ||
|
5e52e5f3bd | ||
|
4178a582e8 | ||
|
67a7576e24 | ||
|
dd208b6e82 |
9 changed files with 119 additions and 284 deletions
|
@ -62,27 +62,22 @@ test sqlite to postgres:
|
||||||
.build-deb:
|
.build-deb:
|
||||||
stage: build
|
stage: build
|
||||||
image: debian:buster
|
image: debian:buster
|
||||||
script:
|
before_script:
|
||||||
- echo deb http://deb.debian.org/debian buster-backports main > /etc/apt/sources.list.d/backports.list
|
- echo deb http://deb.debian.org/debian buster-backports main > /etc/apt/sources.list.d/backports.list
|
||||||
- apt-get update
|
- apt-get update
|
||||||
- apt-get install -y -t buster-backports git-buildpackage dh-golang bash-completion golang-any golang-github-spf13-cobra-dev golang-github-spf13-viper-dev golang-github-google-uuid-dev golang-github-mattn-go-sqlite3-dev golang-github-lib-pq-dev golang-github-satori-go.uuid-dev
|
- apt-get install -y -t buster-backports git-buildpackage dh-golang bash-completion golang-any golang-github-spf13-cobra-dev golang-github-spf13-viper-dev golang-github-google-uuid-dev golang-github-mattn-go-sqlite3-dev golang-github-lib-pq-dev golang-github-satori-go.uuid-dev wget unzip
|
||||||
|
- wget -O golang-github-mdp-qrterminal.zip --quiet "https://gitlab.com/api/v4/projects/signald%2Flibraries%2Fgolang-github-mdp-qrterminal/jobs/artifacts/master/download?job=build"
|
||||||
|
- wget -O golang-github-jedib0t-go-pretty.zip --quiet "https://gitlab.com/api/v4/projects/signald%2Flibraries%2Fgolang-github-jedib0t-go-pretty/jobs/artifacts/master/download?job=build"
|
||||||
|
- for z in *.zip; do unzip $z; done
|
||||||
- apt-get install -y ./*.deb && rm -vf *.deb
|
- apt-get install -y ./*.deb && rm -vf *.deb
|
||||||
|
script:
|
||||||
- 'sed -i "s/^Architecture:.*/Architecture: ${ARCH}/g" debian/control'
|
- 'sed -i "s/^Architecture:.*/Architecture: ${ARCH}/g" debian/control'
|
||||||
- go run ./cmd/signaldctl doc -o man
|
- go run ./cmd/signaldctl doc -o man
|
||||||
- go run ./cmd/signaldctl completion bash > debian/package.bash-completion
|
- go run ./cmd/signaldctl completion bash > debian/package.bash-completion
|
||||||
- ls *.1 > debian/manpages
|
- ls *.1 > debian/manpages
|
||||||
- gbp dch --ignore-branch --debian-tag="%(version)s" --git-author --new-version="$(./version.sh)"
|
- gbp dch --ignore-branch --debian-tag="%(version)s" --git-author --new-version="$(./version.sh | cut -c2-)"
|
||||||
- dpkg-buildpackage -us -uc -b
|
- dpkg-buildpackage -us -uc -b
|
||||||
- mv ../*.deb .
|
- mv ../*.deb .
|
||||||
needs:
|
|
||||||
- project: signald/libraries/golang-github-mdp-qrterminal
|
|
||||||
job: build
|
|
||||||
ref: master
|
|
||||||
artifacts: true
|
|
||||||
- project: signald/libraries/golang-github-jedib0t-go-pretty
|
|
||||||
job: build
|
|
||||||
ref: master
|
|
||||||
artifacts: true
|
|
||||||
variables:
|
variables:
|
||||||
SIGNALDCTL_PUBLIC_DOC_MODE: "on"
|
SIGNALDCTL_PUBLIC_DOC_MODE: "on"
|
||||||
artifacts:
|
artifacts:
|
||||||
|
|
|
@ -34,6 +34,7 @@ import (
|
||||||
var (
|
var (
|
||||||
testing bool
|
testing bool
|
||||||
deviceName string
|
deviceName string
|
||||||
|
overwrite bool
|
||||||
|
|
||||||
LinkAccountCmd = &cobra.Command{
|
LinkAccountCmd = &cobra.Command{
|
||||||
Use: "link",
|
Use: "link",
|
||||||
|
@ -80,6 +81,7 @@ var (
|
||||||
finishReq := v1.FinishLinkRequest{
|
finishReq := v1.FinishLinkRequest{
|
||||||
DeviceName: deviceName,
|
DeviceName: deviceName,
|
||||||
SessionId: response.SessionId,
|
SessionId: response.SessionId,
|
||||||
|
Overwrite: overwrite,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = finishReq.Submit(common.Signald)
|
_, err = finishReq.Submit(common.Signald)
|
||||||
|
@ -99,4 +101,5 @@ func init() {
|
||||||
}
|
}
|
||||||
LinkAccountCmd.Flags().BoolVarP(&testing, "testing", "t", false, "use the Signal testing server")
|
LinkAccountCmd.Flags().BoolVarP(&testing, "testing", "t", false, "use the Signal testing server")
|
||||||
LinkAccountCmd.Flags().StringVarP(&deviceName, "device-name", "n", name, "the name of this device. shown to other devices on the signal account")
|
LinkAccountCmd.Flags().StringVarP(&deviceName, "device-name", "n", name, "the name of this device. shown to other devices on the signal account")
|
||||||
|
LinkAccountCmd.Flags().BoolVar(&overwrite, "overwrite", false, "if an account with the same id already exists in signald's database, delete it before linking")
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,14 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
account string
|
account string
|
||||||
|
name string
|
||||||
|
avatar string
|
||||||
|
emoji string
|
||||||
|
about string
|
||||||
|
|
||||||
SetProfileCmd = &cobra.Command{
|
SetProfileCmd = &cobra.Command{
|
||||||
Use: "set-profile name",
|
Use: "set-profile [name]",
|
||||||
Short: "updates the profile data with a new name",
|
Short: "update an account's profile data",
|
||||||
PreRun: func(cmd *cobra.Command, args []string) {
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
if account == "" {
|
if account == "" {
|
||||||
account = config.Config.DefaultAccount
|
account = config.Config.DefaultAccount
|
||||||
|
@ -39,16 +43,19 @@ var (
|
||||||
common.Must(cmd.Help())
|
common.Must(cmd.Help())
|
||||||
log.Fatal("No account specified. Please specify with --account or set a default")
|
log.Fatal("No account specified. Please specify with --account or set a default")
|
||||||
}
|
}
|
||||||
if len(args) != 1 {
|
|
||||||
common.Must(cmd.Help())
|
if len(args) > 0 {
|
||||||
log.Fatal("must specify a name")
|
name = args[0]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Run: func(_ *cobra.Command, args []string) {
|
Run: func(_ *cobra.Command, _ []string) {
|
||||||
go common.Signald.Listen(nil)
|
go common.Signald.Listen(nil)
|
||||||
req := v1.SetProfile{
|
req := v1.SetProfile{
|
||||||
Account: account,
|
Account: account,
|
||||||
Name: args[0],
|
Name: name,
|
||||||
|
AvatarFile: avatar,
|
||||||
|
Emoji: emoji,
|
||||||
|
About: about,
|
||||||
}
|
}
|
||||||
err := req.Submit(common.Signald)
|
err := req.Submit(common.Signald)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -61,4 +68,7 @@ var (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
SetProfileCmd.Flags().StringVarP(&account, "account", "a", "", "the signald account to use")
|
SetProfileCmd.Flags().StringVarP(&account, "account", "a", "", "the signald account to use")
|
||||||
|
SetProfileCmd.Flags().StringVarP(&avatar, "avatar", "A", "", "path to avatar file")
|
||||||
|
SetProfileCmd.Flags().StringVar(&emoji, "emoji", "", "an emoji to be shown next to the about section")
|
||||||
|
SetProfileCmd.Flags().StringVar(&about, "about", "", "profile about section")
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ var (
|
||||||
{InstalledRank: 4, Version: "14", Description: "multiple identity keys per account", Script: "V14__multiple_identity_keys_per_account.sql", Checksum: -1635788950},
|
{InstalledRank: 4, Version: "14", Description: "multiple identity keys per account", Script: "V14__multiple_identity_keys_per_account.sql", Checksum: -1635788950},
|
||||||
{InstalledRank: 5, Version: "15", Description: "profiles tables", Script: "V15__profiles_tables.sql", Checksum: 809686180},
|
{InstalledRank: 5, Version: "15", Description: "profiles tables", Script: "V15__profiles_tables.sql", Checksum: 809686180},
|
||||||
{InstalledRank: 6, Version: "16", Description: "destination uuid in envelope", Script: "V16__destination_uuid_in_envelope.sql", Checksum: 357656854},
|
{InstalledRank: 6, Version: "16", Description: "destination uuid in envelope", Script: "V16__destination_uuid_in_envelope.sql", Checksum: 357656854},
|
||||||
|
{InstalledRank: 7, Version: "17", Description: "update server ca", Script: "V17__update_server_ca.sql", Checksum: 1647934070},
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlitePath string
|
sqlitePath string
|
||||||
|
@ -60,7 +61,7 @@ var (
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
source, err := sql.Open("sqlite3", sqlitePath)
|
source, err := sql.Open("sqlite3", sqlitePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -93,107 +94,37 @@ var (
|
||||||
}
|
}
|
||||||
log.Println("created schema")
|
log.Println("created schema")
|
||||||
|
|
||||||
if err := moveAccounts(source, dest); err != nil {
|
migrate := func(fn func(*sql.DB, *sql.DB) error, targetName string) {
|
||||||
log.Println("error moving accounts table")
|
if err = fn(source, dest); err != nil {
|
||||||
return err
|
log.Println("error moving", targetName)
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
log.Println("moved", targetName)
|
||||||
}
|
}
|
||||||
log.Println("moved accounts table")
|
defer func() {
|
||||||
|
if r := recover(); r != nil && r != err {
|
||||||
|
// If r is something other than the error returned via the named return, re-panic it
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if err := moveRecipients(source, dest); err != nil {
|
migrate(moveAccounts, "accounts table")
|
||||||
log.Println("error moving recipients table")
|
migrate(moveRecipients, "recipients table")
|
||||||
return err
|
migrate(movePrekeys, "prekeys table")
|
||||||
}
|
migrate(moveSessions, "sessions table")
|
||||||
log.Println("moved recipients table")
|
migrate(moveSignedPrekeys, "signed prekeys table")
|
||||||
|
migrate(moveIdentityKeys, "identity keys table")
|
||||||
if err := movePrekeys(source, dest); err != nil {
|
migrate(moveAccountData, "account data")
|
||||||
log.Println("error moving prekeys table")
|
migrate(movePendingAccountData, "pending account data table")
|
||||||
return err
|
migrate(moveSenderKeys, "sender keys table")
|
||||||
}
|
migrate(moveSenderKeyShared, "sender key shared table")
|
||||||
log.Println("moved prekeys table")
|
migrate(moveGroups, "groups table")
|
||||||
|
migrate(moveGroupCredentials, "group credentials table")
|
||||||
if err := moveSessions(source, dest); err != nil {
|
migrate(moveContacts, "contacts table")
|
||||||
log.Println("error moving sessions table")
|
migrate(moveProfileKeys, "profile keys table")
|
||||||
return err
|
migrate(moveProfiles, "profiles tables")
|
||||||
}
|
migrate(moveProfileCapabilities, "profile capabilities tables")
|
||||||
log.Println("moved sessions table")
|
migrate(moveProfileBadges, "profile badges tables")
|
||||||
|
|
||||||
if err := moveSignedPrekeys(source, dest); err != nil {
|
|
||||||
log.Println("error moving signed prekeys table")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved signed prekeys table")
|
|
||||||
|
|
||||||
if err := moveIdentityKeys(source, dest); err != nil {
|
|
||||||
log.Println("error moving identity keys table")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved identity keys table")
|
|
||||||
|
|
||||||
if err := moveAccountData(source, dest); err != nil {
|
|
||||||
log.Println("error moving account data")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved account data table")
|
|
||||||
|
|
||||||
if err := movePendingAccountData(source, dest); err != nil {
|
|
||||||
log.Println("error moving pending account data tabe")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved pending account data table")
|
|
||||||
|
|
||||||
if err := moveSenderKeys(source, dest); err != nil {
|
|
||||||
log.Println("error moving sender keys table")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved sender keys table")
|
|
||||||
|
|
||||||
if err := moveSenderKeyShared(source, dest); err != nil {
|
|
||||||
log.Println("error moving sender key shared table")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved sender key shared table")
|
|
||||||
|
|
||||||
if err := moveGroups(source, dest); err != nil {
|
|
||||||
log.Println("error moving groups table")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved groups table")
|
|
||||||
|
|
||||||
if err := moveGroupCredentials(source, dest); err != nil {
|
|
||||||
log.Println("error moving group credentials table")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved group credentials table")
|
|
||||||
|
|
||||||
if err := moveContacts(source, dest); err != nil {
|
|
||||||
log.Println("error moving group credentials table")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved contacts table")
|
|
||||||
|
|
||||||
if err := moveProfileKeys(source, dest); err != nil {
|
|
||||||
log.Println("error moving profile keys table")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved profile keys table")
|
|
||||||
|
|
||||||
if err := moveProfiles(source, dest); err != nil {
|
|
||||||
log.Println("error moving profiles tables")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved profiles tables")
|
|
||||||
|
|
||||||
if err := moveProfileCapabilities(source, dest); err != nil {
|
|
||||||
log.Println("error moving profile capabilities tables")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved profile capabilities tables")
|
|
||||||
|
|
||||||
if err := moveProfileBadges(source, dest); err != nil {
|
|
||||||
log.Println("error moving profile badges tables")
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
log.Println("moved profile badges tables")
|
|
||||||
|
|
||||||
if err := os.Remove(sqlitePath); err != nil {
|
if err := os.Remove(sqlitePath); err != nil {
|
||||||
log.Println("error deleting sqlite file")
|
log.Println("error deleting sqlite file")
|
||||||
|
@ -279,7 +210,9 @@ func moveAccounts(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveRecipients(source *sql.DB, dest *sql.DB) error {
|
func moveRecipients(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT rowid, account_uuid, uuid, e164, registered FROM recipients")
|
rows, err := source.Query("SELECT rowid, account_uuid, uuid, e164, registered FROM recipients" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -319,7 +252,9 @@ func moveRecipients(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func movePrekeys(source *sql.DB, dest *sql.DB) error {
|
func movePrekeys(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, id, record FROM prekeys")
|
rows, err := source.Query("SELECT account_uuid, id, record FROM prekeys" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -344,7 +279,10 @@ func movePrekeys(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveSessions(source *sql.DB, dest *sql.DB) error {
|
func moveSessions(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, recipient, device_id, record FROM sessions")
|
rows, err := source.Query("SELECT account_uuid, recipient, device_id, record FROM sessions" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)" +
|
||||||
|
" AND recipient IN (SELECT DISTINCT rowid FROM recipients)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -379,7 +317,9 @@ func moveSessions(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveSignedPrekeys(source *sql.DB, dest *sql.DB) error {
|
func moveSignedPrekeys(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, id, record FROM signed_prekeys")
|
rows, err := source.Query("SELECT account_uuid, id, record FROM signed_prekeys" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -404,7 +344,9 @@ func moveSignedPrekeys(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveIdentityKeys(source *sql.DB, dest *sql.DB) error {
|
func moveIdentityKeys(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, recipient, identity_key, trust_level, added FROM identity_keys")
|
rows, err := source.Query("SELECT account_uuid, recipient, identity_key, trust_level, added FROM identity_keys" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -431,7 +373,9 @@ func moveIdentityKeys(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveAccountData(source *sql.DB, dest *sql.DB) error {
|
func moveAccountData(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, key, value FROM account_data")
|
rows, err := source.Query("SELECT account_uuid, key, value FROM account_data" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -481,7 +425,9 @@ func movePendingAccountData(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveSenderKeys(source *sql.DB, dest *sql.DB) error {
|
func moveSenderKeys(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, address, device, distribution_id, record, created_at FROM sender_keys")
|
rows, err := source.Query("SELECT account_uuid, address, device, distribution_id, record, created_at FROM sender_keys" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -517,7 +463,9 @@ func moveSenderKeys(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveSenderKeyShared(source *sql.DB, dest *sql.DB) error {
|
func moveSenderKeyShared(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, distribution_id, address, device FROM sender_key_shared")
|
rows, err := source.Query("SELECT account_uuid, distribution_id, address, device FROM sender_key_shared" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -553,7 +501,9 @@ func moveSenderKeyShared(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveGroups(source *sql.DB, dest *sql.DB) error {
|
func moveGroups(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT rowid, account_uuid, group_id, master_key, revision, last_avatar_fetch, distribution_id, group_info FROM groups")
|
rows, err := source.Query("SELECT rowid, account_uuid, group_id, master_key, revision, last_avatar_fetch, distribution_id, group_info FROM groups" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -589,7 +539,10 @@ func moveGroups(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveGroupCredentials(source *sql.DB, dest *sql.DB) error {
|
func moveGroupCredentials(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, date, credential FROM group_credentials")
|
rows, err := source.Query("SELECT account_uuid, date, max(credential) FROM group_credentials" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)" +
|
||||||
|
" GROUP BY account_uuid, date",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -614,7 +567,10 @@ func moveGroupCredentials(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveContacts(source *sql.DB, dest *sql.DB) error {
|
func moveContacts(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, recipient, name, color, profile_key, message_expiration_time, inbox_position FROM contacts")
|
rows, err := source.Query("SELECT account_uuid, recipient, name, color, profile_key, message_expiration_time, inbox_position FROM contacts" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)" +
|
||||||
|
" AND recipient IN (SELECT DISTINCT rowid FROM recipients)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -647,7 +603,10 @@ func moveContacts(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveProfileKeys(source *sql.DB, dest *sql.DB) error {
|
func moveProfileKeys(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, recipient, profile_key, profile_key_credential, request_pending, unidentified_access_mode FROM profile_keys")
|
rows, err := source.Query("SELECT account_uuid, recipient, profile_key, profile_key_credential, request_pending, unidentified_access_mode FROM profile_keys" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)" +
|
||||||
|
" AND recipient IN (SELECT DISTINCT rowid FROM recipients)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -679,7 +638,10 @@ func moveProfileKeys(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveProfiles(source *sql.DB, dest *sql.DB) error {
|
func moveProfiles(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, recipient, last_update, given_name, family_name, about, emoji, payment_address, badges FROM profiles")
|
rows, err := source.Query("SELECT account_uuid, recipient, last_update, given_name, family_name, about, emoji, payment_address, badges FROM profiles" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)" +
|
||||||
|
" AND recipient IN (SELECT DISTINCT rowid FROM recipients)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -714,7 +676,10 @@ func moveProfiles(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveProfileCapabilities(source *sql.DB, dest *sql.DB) error {
|
func moveProfileCapabilities(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, recipient, storage, gv1_migration, sender_key, announcement_group, change_number, stories FROM profile_capabilities")
|
rows, err := source.Query("SELECT account_uuid, recipient, storage, gv1_migration, sender_key, announcement_group, change_number, stories FROM profile_capabilities" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)" +
|
||||||
|
" AND recipient IN (SELECT DISTINCT rowid FROM recipients)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -748,7 +713,9 @@ func moveProfileCapabilities(source *sql.DB, dest *sql.DB) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveProfileBadges(source *sql.DB, dest *sql.DB) error {
|
func moveProfileBadges(source *sql.DB, dest *sql.DB) error {
|
||||||
rows, err := source.Query("SELECT account_uuid, id, category, name, description, sprite6 FROM profile_badges")
|
rows, err := source.Query("SELECT account_uuid, id, category, name, description, sprite6 FROM profile_badges" +
|
||||||
|
" WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
package session
|
package session
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -98,30 +98,6 @@ func (r *AddServerRequest) Submit(conn *signald.Signald) (response string, err e
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *AnswerCallRequest) Submit(conn *signald.Signald) (err error) {
|
|
||||||
r.Version = "v1"
|
|
||||||
r.Type = "answer_call"
|
|
||||||
if r.ID == "" {
|
|
||||||
r.ID = signald.GenerateID()
|
|
||||||
}
|
|
||||||
responseChannel := conn.GetResponseListener(r.ID)
|
|
||||||
defer conn.CloseResponseListener(r.ID)
|
|
||||||
err = conn.RawRequest(r)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("signald-go: error submitting request to signald")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
rawResponse := <-responseChannel
|
|
||||||
if rawResponse.Error != nil {
|
|
||||||
err = mkerr(rawResponse)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Submit: approve a request to join a group
|
// Submit: approve a request to join a group
|
||||||
func (r *ApproveMembershipRequest) Submit(conn *signald.Signald) (response JsonGroupV2Info, err error) {
|
func (r *ApproveMembershipRequest) Submit(conn *signald.Signald) (response JsonGroupV2Info, err error) {
|
||||||
r.Version = "v1"
|
r.Version = "v1"
|
||||||
|
@ -617,30 +593,6 @@ func (r *GroupLinkInfoRequest) Submit(conn *signald.Signald) (response JsonGroup
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *HangupCallRequest) Submit(conn *signald.Signald) (err error) {
|
|
||||||
r.Version = "v1"
|
|
||||||
r.Type = "hangup_call"
|
|
||||||
if r.ID == "" {
|
|
||||||
r.ID = signald.GenerateID()
|
|
||||||
}
|
|
||||||
responseChannel := conn.GetResponseListener(r.ID)
|
|
||||||
defer conn.CloseResponseListener(r.ID)
|
|
||||||
err = conn.RawRequest(r)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("signald-go: error submitting request to signald")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
rawResponse := <-responseChannel
|
|
||||||
if rawResponse.Error != nil {
|
|
||||||
err = mkerr(rawResponse)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Submit: Determine whether an account identifier is registered on the Signal service.
|
// Submit: Determine whether an account identifier is registered on the Signal service.
|
||||||
func (r *IsIdentifierRegisteredRequest) Submit(conn *signald.Signald) (response BooleanMessage, err error) {
|
func (r *IsIdentifierRegisteredRequest) Submit(conn *signald.Signald) (response BooleanMessage, err error) {
|
||||||
r.Version = "v1"
|
r.Version = "v1"
|
||||||
|
@ -1127,54 +1079,6 @@ func (r *SendRequest) Submit(conn *signald.Signald) (response SendResponse, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *SendCallOfferRequest) Submit(conn *signald.Signald) (err error) {
|
|
||||||
r.Version = "v1"
|
|
||||||
r.Type = "send_call_offer"
|
|
||||||
if r.ID == "" {
|
|
||||||
r.ID = signald.GenerateID()
|
|
||||||
}
|
|
||||||
responseChannel := conn.GetResponseListener(r.ID)
|
|
||||||
defer conn.CloseResponseListener(r.ID)
|
|
||||||
err = conn.RawRequest(r)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("signald-go: error submitting request to signald")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
rawResponse := <-responseChannel
|
|
||||||
if rawResponse.Error != nil {
|
|
||||||
err = mkerr(rawResponse)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *SendIceUpdatesRequest) Submit(conn *signald.Signald) (err error) {
|
|
||||||
r.Version = "v1"
|
|
||||||
r.Type = "send_ice_updates"
|
|
||||||
if r.ID == "" {
|
|
||||||
r.ID = signald.GenerateID()
|
|
||||||
}
|
|
||||||
responseChannel := conn.GetResponseListener(r.ID)
|
|
||||||
defer conn.CloseResponseListener(r.ID)
|
|
||||||
err = conn.RawRequest(r)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("signald-go: error submitting request to signald")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
rawResponse := <-responseChannel
|
|
||||||
if rawResponse.Error != nil {
|
|
||||||
err = mkerr(rawResponse)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Submit: send a mobilecoin payment
|
// Submit: send a mobilecoin payment
|
||||||
func (r *SendPaymentRequest) Submit(conn *signald.Signald) (response SendResponse, err error) {
|
func (r *SendPaymentRequest) Submit(conn *signald.Signald) (response SendResponse, err error) {
|
||||||
r.Version = "v1"
|
r.Version = "v1"
|
||||||
|
|
|
@ -49,16 +49,6 @@ type AllIdentityKeyList struct {
|
||||||
IdentityKeys []*IdentityKeyList `json:"identity_keys,omitempty" yaml:"identity_keys,omitempty"`
|
IdentityKeys []*IdentityKeyList `json:"identity_keys,omitempty" yaml:"identity_keys,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AnswerCallRequest struct {
|
|
||||||
Request
|
|
||||||
Account string `json:"account,omitempty" yaml:"account,omitempty"` // the local account to use
|
|
||||||
CallId int64 `json:"call_id,omitempty" yaml:"call_id,omitempty"` // the id of the call
|
|
||||||
DestinationDeviceId int32 `json:"destination_device_id,omitempty" yaml:"destination_device_id,omitempty"`
|
|
||||||
Multiring bool `json:"multiring,omitempty" yaml:"multiring,omitempty"`
|
|
||||||
Recipient *JsonAddress `json:"recipient,omitempty" yaml:"recipient,omitempty"` // the address of the caller
|
|
||||||
Sdp string `json:"sdp,omitempty" yaml:"sdp,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AnswerMessage struct {
|
type AnswerMessage struct {
|
||||||
ID int64 `json:"id,omitempty" yaml:"id,omitempty"`
|
ID int64 `json:"id,omitempty" yaml:"id,omitempty"`
|
||||||
Opaque string `json:"opaque,omitempty" yaml:"opaque,omitempty"`
|
Opaque string `json:"opaque,omitempty" yaml:"opaque,omitempty"`
|
||||||
|
@ -294,17 +284,6 @@ type GroupRequestingMember struct {
|
||||||
UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
UUID string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type HangupCallRequest struct {
|
|
||||||
Request
|
|
||||||
Account string `json:"account,omitempty" yaml:"account,omitempty"` // the local account to use
|
|
||||||
CallId int64 `json:"call_id,omitempty" yaml:"call_id,omitempty"` // the id of the call
|
|
||||||
DestinationDeviceId int32 `json:"destination_device_id,omitempty" yaml:"destination_device_id,omitempty"`
|
|
||||||
DeviceId int32 `json:"device_id,omitempty" yaml:"device_id,omitempty"`
|
|
||||||
Multiring bool `json:"multiring,omitempty" yaml:"multiring,omitempty"`
|
|
||||||
Recipient *JsonAddress `json:"recipient,omitempty" yaml:"recipient,omitempty"` // the address of the caller
|
|
||||||
Type string `json:"type,omitempty" yaml:"type,omitempty"` // hangup type, options are: normal, accepted, declined, busy, need_permission
|
|
||||||
}
|
|
||||||
|
|
||||||
type HangupMessage struct {
|
type HangupMessage struct {
|
||||||
DeviceId int32 `json:"device_id,omitempty" yaml:"device_id,omitempty"`
|
DeviceId int32 `json:"device_id,omitempty" yaml:"device_id,omitempty"`
|
||||||
ID int64 `json:"id,omitempty" yaml:"id,omitempty"`
|
ID int64 `json:"id,omitempty" yaml:"id,omitempty"`
|
||||||
|
@ -314,9 +293,7 @@ type HangupMessage struct {
|
||||||
|
|
||||||
type IceUpdateMessage struct {
|
type IceUpdateMessage struct {
|
||||||
ID int64 `json:"id,omitempty" yaml:"id,omitempty"`
|
ID int64 `json:"id,omitempty" yaml:"id,omitempty"`
|
||||||
Line int32 `json:"line,omitempty" yaml:"line,omitempty"`
|
Opaque string `json:"opaque,omitempty" yaml:"opaque,omitempty"`
|
||||||
Mid string `json:"mid,omitempty" yaml:"mid,omitempty"`
|
|
||||||
Opaque string `json:"opaque,omitempty" yaml:"opaque,omitempty"` // the base64 encoded protobuf value.
|
|
||||||
Sdp string `json:"sdp,omitempty" yaml:"sdp,omitempty"`
|
Sdp string `json:"sdp,omitempty" yaml:"sdp,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,26 +718,6 @@ type ResolveAddressRequest struct {
|
||||||
Partial *JsonAddress `json:"partial,omitempty" yaml:"partial,omitempty"` // The partial address, missing fields
|
Partial *JsonAddress `json:"partial,omitempty" yaml:"partial,omitempty"` // The partial address, missing fields
|
||||||
}
|
}
|
||||||
|
|
||||||
type SendCallOfferRequest struct {
|
|
||||||
Request
|
|
||||||
Account string `json:"account,omitempty" yaml:"account,omitempty"` // the local account to use
|
|
||||||
CallId int64 `json:"call_id,omitempty" yaml:"call_id,omitempty"` // the id of the call
|
|
||||||
CallType string `json:"call_type,omitempty" yaml:"call_type,omitempty"` // must be one of 'audio_call' or 'video_call'
|
|
||||||
DestinationDeviceId int32 `json:"destination_device_id,omitempty" yaml:"destination_device_id,omitempty"`
|
|
||||||
Multring bool `json:"multring,omitempty" yaml:"multring,omitempty"`
|
|
||||||
Recipient *JsonAddress `json:"recipient,omitempty" yaml:"recipient,omitempty"` // the address of the caller
|
|
||||||
Sdp string `json:"sdp,omitempty" yaml:"sdp,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SendIceUpdatesRequest struct {
|
|
||||||
Request
|
|
||||||
Account string `json:"account,omitempty" yaml:"account,omitempty"` // the local account to use
|
|
||||||
DestinationDeviceId int32 `json:"destination_device_id,omitempty" yaml:"destination_device_id,omitempty"`
|
|
||||||
Multiring bool `json:"multiring,omitempty" yaml:"multiring,omitempty"`
|
|
||||||
Recipient *JsonAddress `json:"recipient,omitempty" yaml:"recipient,omitempty"` // the address of the caller
|
|
||||||
Updates []*IceUpdateMessage `json:"updates,omitempty" yaml:"updates,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SendPaymentRequest: send a mobilecoin payment
|
// SendPaymentRequest: send a mobilecoin payment
|
||||||
type SendPaymentRequest struct {
|
type SendPaymentRequest struct {
|
||||||
Request
|
Request
|
||||||
|
|
|
@ -99,13 +99,12 @@ func (s *Signald) connect() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (s *Signald) Close() error {
|
func (s *Signald) Close() error {
|
||||||
return s.socket.Close()
|
return s.socket.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen listens for events from signald
|
// Listen listens for events from signald
|
||||||
func (s *Signald) Listen(c chan client_protocol.BasicResponse) {
|
func (s *Signald) Listen(c chan client_protocol.BasicResponse) error {
|
||||||
for {
|
for {
|
||||||
msg, err := s.readNext()
|
msg, err := s.readNext()
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
@ -113,7 +112,11 @@ func (s *Signald) Listen(c chan client_protocol.BasicResponse) {
|
||||||
if c != nil {
|
if c != nil {
|
||||||
close(c)
|
close(c)
|
||||||
}
|
}
|
||||||
return
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if msg.Type == "unexpected_error" {
|
if msg.Type == "unexpected_error" {
|
||||||
|
@ -175,9 +178,6 @@ func (s *Signald) readNext() (b client_protocol.BasicResponse, err error) {
|
||||||
} else {
|
} else {
|
||||||
err = json.NewDecoder(s.socket).Decode(&b)
|
err = json.NewDecoder(s.socket).Decode(&b)
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
log.Println("signald-go: error decoding message from signald:", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue