linkedin_orbit 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d153344cbc2b2e493076481c82338b674c983304e812dfde4ea8b401e1ac17c
4
- data.tar.gz: 01deb03d1642d62655ff4f63f5bbaafc8c0902396ff034b50c0c60bf83e613b8
3
+ metadata.gz: e5ce815b2bef824b0a24e66ed92496598fcd82a9750f246690bc2c5c780f34ab
4
+ data.tar.gz: 40fb98e7676dd2bb144c45a24d9b4d8240f4c31d9c7df7db882b7940923fc5e4
5
5
  SHA512:
6
- metadata.gz: 982b06fd0771e316f10777898a0e7002af7a6d53dc6e790cc2c2e0720423813484362cdc954ed4136484fb238e1f728d4786d42024ff70c0ecf17a9683d0455a
7
- data.tar.gz: 960f1217736db479c1088cfa9fa3ef317db1396e0142981af13aaf8b09b7ee1b4b7e196bbfa2fdb1d8653833ccb934d6cc69bbcbc3c5fcf02de7a97406cfc0de
6
+ metadata.gz: d5d583d563f04131aa565ed6bee6ee28bf515965bfb9a91fa4ee330b8a1579d33c2e8bc0c8b547552855cd8be648283cb774dab77fb75dbbb6323be94f524069
7
+ data.tar.gz: 38ea6fd791f1583224229d479f01bfc83b549b7616731e0fc22c370fd195efc6c36a17e35907aae661479de11e63a8c0422db0f75a4681b8352948816f218327
@@ -34,6 +34,7 @@ module LinkedinOrbit
34
34
  occurred_at: Time.at(@comment["created"]["time"] / 1000).utc,
35
35
  key: @comment["id"],
36
36
  link: "https://www.linkedin.com/feed/update/#{@comment["object"]}",
37
+ link_text: "View on LinkedIn",
37
38
  member: {
38
39
  name: name
39
40
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
-
2
+ require "byebug"
3
3
  module LinkedinOrbit
4
4
  class Linkedin
5
5
  def initialize(params = {})
@@ -16,16 +16,29 @@ module LinkedinOrbit
16
16
  return posts unless posts.is_a?(Array)
17
17
 
18
18
  orbit_timestamp = last_orbit_activity_timestamp
19
-
20
- posts.each do |post|
21
- times = 0
22
19
 
20
+ times = 0
21
+ posts.each do |post|
22
+
23
23
  comments = get_post_comments(post["id"])
24
24
 
25
- comments.reject! { |comment| comment["actor~"]["id"] == "private" }
26
-
27
25
  next if comments.nil? || comments.empty?
28
26
 
27
+ # Indicates that the member does not want their information shared
28
+ # Member viewing access if forbidden for profile memberId
29
+ comments.reject! do |comment|
30
+ if comment.has_key? "actor!"
31
+ true if comment["actor!"]["status"] == 403
32
+ end
33
+ end
34
+
35
+ # Indicates that the member does not want their information shared
36
+ comments.reject! do |comment|
37
+ if comment.has_key? "actor~"
38
+ true if comment["actor~"]["id"] == "private"
39
+ end
40
+ end
41
+
29
42
  comments.each do |comment|
30
43
  unless @historical_import && orbit_timestamp
31
44
  next if Time.at(comment["created"]["time"] / 1000).utc.to_s < orbit_timestamp unless orbit_timestamp.nil?
@@ -47,27 +60,28 @@ module LinkedinOrbit
47
60
  orbit_api_key: @orbit_api_key
48
61
  )
49
62
  end
50
-
51
- output = "Sent #{times} new comments to your Orbit workspace"
52
-
53
- puts output
54
- return output
55
63
  end
64
+
65
+ output = "Sent #{times} new comments to your Orbit workspace"
66
+
67
+ puts output
68
+ return output
56
69
  end
57
70
 
58
71
  def get_posts
59
72
  posts = []
60
73
  page = 0
61
74
  count = 100
62
- looped_at_least_once = false
75
+ total = 0
63
76
 
64
- while page >= 0
65
- url = URI("https://api.linkedin.com/v2/shares?q=owners&owners=#{@linkedin_organization}&start=#{page}&count=#{count}")
77
+ while page * count <= total
78
+ url = URI("https://api.linkedin.com/v2/ugcPosts?q=authors&authors=List(#{CGI.escape(@linkedin_organization)})&sortBy=LAST_MODIFIED&start=#{page*count}&count=#{count}")
66
79
  https = Net::HTTP.new(url.host, url.port)
67
80
  https.use_ssl = true
68
81
 
69
82
  request = Net::HTTP::Get.new(url)
70
83
  request["Accept"] = "application/json"
84
+ request["X-Restli-Protocol-Version"] = "2.0.0"
71
85
  request["Content-Type"] = "application/json"
72
86
  request["Authorization"] = "Bearer #{@linkedin_token}"
73
87
 
@@ -75,6 +89,8 @@ module LinkedinOrbit
75
89
 
76
90
  response = JSON.parse(response.body)
77
91
 
92
+ total = response["paging"]["total"] if page == 0
93
+
78
94
  return response["message"] if response["serviceErrorCode"]
79
95
 
80
96
  if response["elements"].nil? || response["elements"].empty?
@@ -85,16 +101,13 @@ module LinkedinOrbit
85
101
  end
86
102
 
87
103
  response["elements"].each do |element|
104
+ next if element["id"].nil?
88
105
  posts << {
89
- "id" => element["activity"],
90
- "message_highlight" => element["text"]["text"][0, 40]
106
+ "id" => element["id"],
107
+ "message_highlight" => element["specificContent"]["com.linkedin.ugc.ShareContent"]["shareCommentary"]["text"][0, 40]
91
108
  }
92
109
  end
93
-
94
- break if response["elements"].count < count
95
-
96
- looped_at_least_once = true
97
- page += 1 if looped_at_least_once
110
+ page += 1
98
111
  end
99
112
 
100
113
  posts
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LinkedinOrbit
4
- VERSION = "0.3.0"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -5,7 +5,7 @@ require_relative "lib/linkedin_orbit/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "linkedin_orbit"
7
7
  spec.version = LinkedinOrbit::VERSION
8
- spec.authors = ["Orbit DevRel", "Ben Greenberg"]
8
+ spec.authors = ["Orbit DevRel", "Ben Greenberg", "Colin Loretz"]
9
9
  spec.email = ["devrel@orbit.love"]
10
10
 
11
11
  spec.summary = "Integrate LinkedIn interactions into Orbit"
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linkedin_orbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Orbit DevRel
8
8
  - Ben Greenberg
9
- autorequire:
9
+ - Colin Loretz
10
+ autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2021-07-12 00:00:00.000000000 Z
13
+ date: 2021-12-21 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: http
@@ -183,7 +184,7 @@ metadata:
183
184
  homepage_uri: https://github.com/orbit-love/community-ruby-linkedin-orbit
184
185
  source_code_uri: https://github.com/orbit-love/community-ruby-linkedin-orbit
185
186
  changelog_uri: https://github.com/orbit-love/community-ruby-linkedin-orbit/blob/main/CHANGELOG.md
186
- post_install_message:
187
+ post_install_message:
187
188
  rdoc_options: []
188
189
  require_paths:
189
190
  - lib
@@ -198,8 +199,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
199
  - !ruby/object:Gem::Version
199
200
  version: '0'
200
201
  requirements: []
201
- rubygems_version: 3.2.15
202
- signing_key:
202
+ rubygems_version: 3.1.4
203
+ signing_key:
203
204
  specification_version: 4
204
205
  summary: Integrate LinkedIn interactions into Orbit
205
206
  test_files: []