Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cedws committed Mar 28, 2021
1 parent 3f2e710 commit 520eb97
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ func (c *Client) PartialDelete() error {
}

for _, channel := range channels {
if c.skipChannel(channel.ID) {
log.Infof("Skipping message deletion for channel %v", channel.ID)
continue
}

err = c.DeleteFromChannel(me, &channel)
if err != nil {
return err
Expand Down Expand Up @@ -102,11 +97,9 @@ Relationships:

log.Infof("Resolved relationship with '%v' to channel %v", relation.Recipient.Username, channel.ID)

if !c.skipChannel(channel.ID) {
err = c.DeleteFromChannel(me, channel)
if err != nil {
return err
}
err = c.DeleteFromChannel(me, channel)
if err != nil {
return err
}
}

Expand All @@ -115,11 +108,6 @@ Relationships:
return errors.Wrap(err, "Error fetching guilds")
}
for _, guild := range guilds {
if c.skipChannel(guild.ID) {
log.Infof("Skipping message deletion for guild '%v'", guild.Name)
continue
}

err = c.DeleteFromGuild(me, &guild)
if err != nil {
return err
Expand All @@ -132,6 +120,11 @@ Relationships:
}

func (c *Client) DeleteFromChannel(me *Me, channel *Channel) error {
if c.skipChannel(channel.ID) {
log.Infof("Skipping message deletion for channel %v", channel.ID)
return nil
}

seek := 0

for {
Expand All @@ -154,6 +147,11 @@ func (c *Client) DeleteFromChannel(me *Me, channel *Channel) error {
}

func (c *Client) DeleteFromGuild(me *Me, channel *Channel) error {
if c.skipChannel(channel.ID) {
log.Infof("Skipping message deletion for guild '%v'", channel.Name)
return nil
}

seek := 0

for {
Expand Down Expand Up @@ -207,8 +205,8 @@ func (c *Client) DeleteMessages(messages *Messages, seek *int) error {
// Check if this message is in our list of channels to skip
// This will only skip this specific message and increment the seek index
// Entire channels should be skipped at the caller of this function
// We do it this way because we search guilds returns a mix of messages from
// any channel
// We do it this way because guilds searches return a mix of messages
// from any channel
if c.skipChannel(hit.ChannelID) {
log.Infof("Skipping message deletion for channel %v", hit.ChannelID)
(*seek)++
Expand Down

0 comments on commit 520eb97

Please sign in to comment.