Skip to content

Pretty messages#6

Open
ian-cameron wants to merge 4 commits intotamhinsf:masterfrom
kittelson:PrettyMessages
Open

Pretty messages#6
ian-cameron wants to merge 4 commits intotamhinsf:masterfrom
kittelson:PrettyMessages

Conversation

@ian-cameron
Copy link

We wanted the exported message history to be a little more user-friendly by formatting the timestamp nicely, and showing user mentions by username instead of user_id. Implemented DetectSlackParens. Also skipped importing archived channels.

@TheFlyingPig
Copy link

So, I'm considering using this tool and was wondering how hard it is to use, in doing that I thought I'd have a look here. Personally, I think skipping archived channels should be optional, we have a channel for each release, so each time we start from a clean slate, each channel that we are finished with is then archived.

I suppose this could be worked around by un-archiving the channels in the Slack export (I guess you could do that?). Anyway, just my 2 cents.

@JanisE
Copy link

JanisE commented Apr 6, 2020

@ian-cameron , I'm trying to use your code, but I'm getting this error messages upon the first message JSON file ChannelSurf is trying to process:

File /tmp/tmpEnmzuk.tmp/random/2018-11-20.json

Unhandled Exception: System.FormatException: Input string was not in a correct format.
   at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
   at System.Double.Parse(String s)
   at ChannelSurfCli.Utils.Messages.GetAndUploadMessages(ChannelsMapping channelsMapping, String basePath, List`1 slackUserList, String aadAccessToken, String selectedTeamId, Boolean copyFileAttachments) in /home/janis/Darbs/migrat/ChannelSurf/ChannelSurfCli/Utils/Messages.cs:line 58
   at ChannelSurfCli.Utils.Messages.ScanMessagesByChannel(List`1 channelsMapping, String basePath, List`1 slackUserList, String aadAccessToken, String selectedTeamId, Boolean copyFileAttachments) in /home/janis/Darbs/migrat/ChannelSurf/ChannelSurfCli/Utils/Messages.cs:line 20
   at ChannelSurfCli.Program.Main(String[] args) in /home/janis/Darbs/migrat/ChannelSurf/ChannelSurfCli/Program.cs:line 168

Messages.cs:line 58 is:

var messageTs = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(Double.Parse((string)obj.SelectToken("ts")));

And if I open the file 2018-11-20.json, the ts fields contain values like:

[
    {
        [..]
        "ts": "1542704352.000200",
        [..]
    },
    {
        [..]
        "ts": "1542704914.000400",
        [..]
    },
    {
        [..]
        "ts": "1542705149.000600",
        [..]
    },
    [..]

What do you think could be the problem?
Could it be because the timestamp is not integer?
Could this parsing depend on the locale (the decimal separator in my locale is comma, not dot)?

@ian-cameron
Copy link
Author

@JanisE Yes its probably the comma. Sorry this code wasn't written with that in mind. You can use something like this in Message.cs just to get it working for you.

using System.Globalization;
....
var provider = CultureInfo.CreateSpecificCulture("af-ZA");
var messageTs = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(Double.Parse((string)obj.SelectToken("ts"), NumberStyles.Float, provider));

@JanisE
Copy link

JanisE commented Apr 6, 2020

Thank you for the reply!

I already tried simply to cut off anything after the 10th digit, and seems to have worked:

var messageTs = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(Double.Parse(((string)obj.SelectToken("ts")).Substring(0, 10)));

@iradzik
Copy link

iradzik commented Apr 28, 2020

does this branch allow Teams to import the conversations into the channels so that they are searchable?

@JanisE
Copy link

JanisE commented Apr 28, 2020

@iradzik , no, it does not.

@iradzik
Copy link

iradzik commented Apr 28, 2020

is there any way to import the Jsons into the messages portion of teams?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants