Compare commits

..

No commits in common. "main" and "fix-deb-build" have entirely different histories.

9 changed files with 5568 additions and 105 deletions

View file

@ -62,15 +62,11 @@ test sqlite to postgres:
.build-deb: .build-deb:
stage: build stage: build
image: debian:buster image: debian:buster
before_script: 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 wget unzip - 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 -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
@ -78,6 +74,15 @@ test sqlite to postgres:
- gbp dch --ignore-branch --debian-tag="%(version)s" --git-author --new-version="$(./version.sh | cut -c2-)" - 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:

View file

@ -34,7 +34,6 @@ import (
var ( var (
testing bool testing bool
deviceName string deviceName string
overwrite bool
LinkAccountCmd = &cobra.Command{ LinkAccountCmd = &cobra.Command{
Use: "link", Use: "link",
@ -81,7 +80,6 @@ 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)
@ -101,5 +99,4 @@ 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")
} }

View file

@ -27,14 +27,10 @@ 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: "update an account's profile data", Short: "updates the profile data with a new name",
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
@ -43,19 +39,16 @@ 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 {
if len(args) > 0 { common.Must(cmd.Help())
name = args[0] log.Fatal("must specify a name")
} }
}, },
Run: func(_ *cobra.Command, _ []string) { Run: func(_ *cobra.Command, args []string) {
go common.Signald.Listen(nil) go common.Signald.Listen(nil)
req := v1.SetProfile{ req := v1.SetProfile{
Account: account, Account: account,
Name: name, Name: args[0],
AvatarFile: avatar,
Emoji: emoji,
About: about,
} }
err := req.Submit(common.Signald) err := req.Submit(common.Signald)
if err != nil { if err != nil {
@ -68,7 +61,4 @@ 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")
} }

View file

@ -33,7 +33,6 @@ 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
@ -210,9 +209,7 @@ 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
} }
@ -252,9 +249,7 @@ 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
} }
@ -279,10 +274,7 @@ 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
} }
@ -317,9 +309,7 @@ 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
} }
@ -344,9 +334,7 @@ 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
} }
@ -373,9 +361,7 @@ 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
} }
@ -425,9 +411,7 @@ 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
} }
@ -463,9 +447,7 @@ 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
} }
@ -501,9 +483,7 @@ 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
} }
@ -539,10 +519,7 @@ 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, max(credential) FROM group_credentials" + rows, err := source.Query("SELECT account_uuid, date, 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
} }
@ -568,8 +545,7 @@ 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)" + " 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
@ -603,10 +579,7 @@ 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
} }
@ -638,10 +611,7 @@ 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
} }
@ -676,10 +646,7 @@ 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
} }
@ -713,9 +680,7 @@ 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
} }

View file

@ -15,6 +15,7 @@
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

View file

@ -284,13 +284,6 @@ func mkerr(response client_protocol.BasicResponse) error {
return err return err
} }
return result return result
case "UnsupportedGroupError":
result := UnsupportedGroupError{}
err := json.Unmarshal(response.Error, &result)
if err != nil {
return err
}
return result
case "UntrustedIdentityError": case "UntrustedIdentityError":
result := UntrustedIdentityError{} result := UntrustedIdentityError{}
err := json.Unmarshal(response.Error, &result) err := json.Unmarshal(response.Error, &result)
@ -652,15 +645,6 @@ func (e UnregisteredUserError) Error() string {
return e.Message return e.Message
} }
// UnsupportedGroupError: returned in response to use v1 groups, which are no longer supported
type UnsupportedGroupError struct {
Message string `json:"message,omitempty" yaml:"message,omitempty"`
}
func (e UnsupportedGroupError) Error() string {
return e.Message
}
type UntrustedIdentityError struct { type UntrustedIdentityError struct {
Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"` Identifier string `json:"identifier,omitempty" yaml:"identifier,omitempty"`
IdentityKey **IdentityKey `json:"identity_key,omitempty" yaml:"identity_key,omitempty"` IdentityKey **IdentityKey `json:"identity_key,omitempty" yaml:"identity_key,omitempty"`

View file

@ -263,7 +263,7 @@ type GroupLinkInfoRequest struct {
type GroupList struct { type GroupList struct {
Groups []*JsonGroupV2Info `json:"groups,omitempty" yaml:"groups,omitempty"` Groups []*JsonGroupV2Info `json:"groups,omitempty" yaml:"groups,omitempty"`
LegacyGroups []*JsonGroupInfo `json:"legacyGroups,omitempty" yaml:"legacyGroups,omitempty"` // list of legacy (v1) groups, no longer supported (will always be empty) LegacyGroups []*JsonGroupInfo `json:"legacyGroups,omitempty" yaml:"legacyGroups,omitempty"`
} }
type GroupMember struct { type GroupMember struct {
@ -492,7 +492,6 @@ type JsonSentTranscriptMessage struct {
ExpirationStartTimestamp int64 `json:"expirationStartTimestamp,omitempty" yaml:"expirationStartTimestamp,omitempty"` ExpirationStartTimestamp int64 `json:"expirationStartTimestamp,omitempty" yaml:"expirationStartTimestamp,omitempty"`
IsRecipientUpdate bool `json:"isRecipientUpdate,omitempty" yaml:"isRecipientUpdate,omitempty"` IsRecipientUpdate bool `json:"isRecipientUpdate,omitempty" yaml:"isRecipientUpdate,omitempty"`
Message *JsonDataMessage `json:"message,omitempty" yaml:"message,omitempty"` Message *JsonDataMessage `json:"message,omitempty" yaml:"message,omitempty"`
Story *StoryMessage `json:"story,omitempty" yaml:"story,omitempty"`
Timestamp int64 `json:"timestamp,omitempty" yaml:"timestamp,omitempty"` Timestamp int64 `json:"timestamp,omitempty" yaml:"timestamp,omitempty"`
UnidentifiedStatus map[string]string `json:"unidentifiedStatus,omitempty" yaml:"unidentifiedStatus,omitempty"` UnidentifiedStatus map[string]string `json:"unidentifiedStatus,omitempty" yaml:"unidentifiedStatus,omitempty"`
} }
@ -600,8 +599,7 @@ type Profile struct {
Address *JsonAddress `json:"address,omitempty" yaml:"address,omitempty"` Address *JsonAddress `json:"address,omitempty" yaml:"address,omitempty"`
Avatar string `json:"avatar,omitempty" yaml:"avatar,omitempty"` // path to avatar on local disk Avatar string `json:"avatar,omitempty" yaml:"avatar,omitempty"` // path to avatar on local disk
Capabilities *Capabilities `json:"capabilities,omitempty" yaml:"capabilities,omitempty"` Capabilities *Capabilities `json:"capabilities,omitempty" yaml:"capabilities,omitempty"`
Color string `json:"color,omitempty" yaml:"color,omitempty"` // color of the chat with this user Color string `json:"color,omitempty" yaml:"color,omitempty"` // color of the chat with this user
ContactName string `json:"contact_name,omitempty" yaml:"contact_name,omitempty"` // The user's name from local contact names
Emoji string `json:"emoji,omitempty" yaml:"emoji,omitempty"` Emoji string `json:"emoji,omitempty" yaml:"emoji,omitempty"`
ExpirationTime int32 `json:"expiration_time,omitempty" yaml:"expiration_time,omitempty"` ExpirationTime int32 `json:"expiration_time,omitempty" yaml:"expiration_time,omitempty"`
InboxPosition int32 `json:"inbox_position,omitempty" yaml:"inbox_position,omitempty"` InboxPosition int32 `json:"inbox_position,omitempty" yaml:"inbox_position,omitempty"`

View file

@ -99,12 +99,13 @@ 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) error { func (s *Signald) Listen(c chan client_protocol.BasicResponse) {
for { for {
msg, err := s.readNext() msg, err := s.readNext()
if err == io.EOF { if err == io.EOF {
@ -112,11 +113,7 @@ func (s *Signald) Listen(c chan client_protocol.BasicResponse) error {
if c != nil { if c != nil {
close(c) close(c)
} }
return nil return
}
if err != nil {
return err
} }
if msg.Type == "unexpected_error" { if msg.Type == "unexpected_error" {
@ -178,6 +175,9 @@ 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
} }