Skip to content

Commit 9818cb7

Browse files
committed
Update LinkedIn to Go version
1 parent 726f484 commit 9818cb7

File tree

6 files changed

+29
-369
lines changed

6 files changed

+29
-369
lines changed

api/gitlab/build.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func getRefFromBridge(bridge string) (string, error) {
7070
switch bridge {
7171
case "imessage":
7272
return "master", nil
73-
case "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "imessagego", "meta", "twitter", "bluesky":
73+
case "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "imessagego", "meta", "twitter", "bluesky", "linkedin":
7474
return "main", nil
7575
default:
7676
return "", fmt.Errorf("unknown bridge %s", bridge)
@@ -165,7 +165,7 @@ func downloadFile(ctx context.Context, artifactURL, path string) error {
165165

166166
func needsLibolmDylib(bridge string) bool {
167167
switch bridge {
168-
case "imessage", "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "imessagego", "meta", "twitter", "bluesky":
168+
case "imessage", "whatsapp", "discord", "slack", "gmessages", "gvoice", "signal", "imessagego", "meta", "twitter", "bluesky", "linkedin":
169169
return runtime.GOOS == "darwin"
170170
default:
171171
return false

bridgeconfig/linkedin.tpl.yaml

Lines changed: 22 additions & 350 deletions
Original file line numberDiff line numberDiff line change
@@ -1,351 +1,23 @@
1-
# Homeserver details
2-
homeserver:
3-
# The address that this appservice can use to connect to the homeserver.
4-
address: {{ .HungryAddress }}
5-
# The domain of the homeserver (for MXIDs, etc).
6-
domain: beeper.local
7-
# Whether or not to verify the SSL certificate of the homeserver.
8-
# Only applies if address starts with https://
9-
verify_ssl: true
10-
# What software is the homeserver running?
11-
# Standard Matrix homeservers like Synapse, Dendrite and Conduit should just use "standard" here.
12-
software: hungry
13-
# Number of retries for all HTTP requests if the homeserver isn't reachable.
14-
http_retry_count: 4
15-
# The URL to push real-time bridge status to.
16-
# If set, the bridge will make POST requests to this URL whenever a user's Signal connection state changes.
17-
# The bridge will use the appservice as_token to authorize requests.
18-
status_endpoint: null
19-
# Endpoint for reporting per-message status.
20-
message_send_checkpoint_endpoint: null
21-
# Whether asynchronous uploads via MSC2246 should be enabled for media.
22-
# Requires a media repo that supports MSC2246.
23-
async_media: true
24-
25-
# Application service host/registration related details
26-
# Changing these values requires regeneration of the registration.
27-
appservice:
28-
# The address that the homeserver can use to connect to this appservice.
29-
address: "http://{{ .ListenAddr }}:{{ .ListenPort }}"
30-
31-
# The hostname and port where this appservice should listen.
32-
hostname: {{ .ListenAddr }}
33-
port: {{ .ListenPort }}
34-
# The maximum body size of appservice API requests (from the homeserver) in mebibytes
35-
# Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s
36-
max_body_size: 1
37-
38-
# The full URI to the database. SQLite and Postgres are supported.
39-
# Format examples:
40-
# SQLite: sqlite:filename.db
41-
# Postgres: postgres://username:password@hostname/dbname
42-
database: sqlite:{{.DatabasePrefix}}beeper-linkedin.db
43-
# Additional arguments for asyncpg.create_pool() or sqlite3.connect()
44-
# https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.pool.create_pool
45-
# https://docs.python.org/3/library/sqlite3.html#sqlite3.connect
46-
# For sqlite, min_size is used as the connection thread pool size and max_size is ignored.
47-
# Additionally, SQLite supports init_commands as an array of SQL queries to run on connect (e.g. to set PRAGMAs).
48-
database_opts:
49-
min_size: 1
50-
max_size: 1
51-
52-
# Provisioning API part of the web server for automated portal creation and fetching information.
53-
# Used by things like mautrix-manager (https://github.com/tulir/mautrix-manager).
54-
provisioning:
55-
# Whether or not the provisioning API should be enabled.
56-
enabled: true
57-
# The prefix to use in the provisioning API endpoints.
58-
prefix: /_matrix/provision
59-
# The shared secret to authorize users of the API.
60-
# Set to "generate" to generate and save a new token.
61-
shared_secret: {{ .ProvisioningSecret }}
62-
63-
# The unique ID of this appservice.
64-
id: {{ .AppserviceID }}
65-
# Username of the appservice bot.
66-
bot_username: {{ .BridgeName }}bot
67-
# Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
68-
# to leave display name/avatar as-is.
69-
bot_displayname: LinkedIn bridge bot
70-
bot_avatar: mxc://nevarro.space/cwsWnmeMpWSMZLUNblJHaIvP
71-
72-
# Whether or not to receive ephemeral events via appservice transactions.
73-
# Requires MSC2409 support (i.e. Synapse 1.22+).
74-
# You should disable bridge -> sync_with_custom_puppets when this is enabled.
75-
ephemeral_events: true
76-
77-
# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
78-
as_token: {{ .ASToken }}
79-
hs_token: {{ .HSToken }}
80-
81-
# Segment-compatible analytics endpoint for tracking some events, like provisioning API login and encryption errors.
82-
analytics:
83-
# Hostname of the tracking server. The path is hardcoded to /v1/track
84-
host: api.segment.io
85-
# API key to send with tracking requests. Tracking is disabled if this is null.
86-
token: null
87-
# Optional user ID for tracking events. If null, defaults to using Matrix user ID.
88-
user_id: null
89-
90-
# Prometheus telemetry config. Requires prometheus-client to be installed.
91-
metrics:
92-
enabled: false
93-
listen_port: 8000
94-
95-
# Manhole config.
96-
manhole:
97-
# Whether or not opening the manhole is allowed.
98-
enabled: false
99-
# The path for the unix socket.
100-
path: /var/tmp/linkedin-matrix.manhole
101-
# The list of UIDs who can be added to the whitelist.
102-
# If empty, any UIDs can be specified in the open-manhole command.
103-
whitelist:
104-
- 0
105-
106-
# Bridge config
107-
bridge:
108-
# Localpart template of MXIDs for LinkedIn users.
109-
# {userid} is replaced with the user ID of the LinkedIn user.
110-
username_template: "{{ .BridgeName }}_{userid}"
111-
# Settings for creating a space for every user.
112-
space_support:
113-
# Whether or not to enable creating a space per user and inviting the
114-
# user (as well as all of the puppets) to that space.
115-
enable: false
116-
# The name of the space
117-
name: "LinkedIn"
1+
# Network-specific config options
2+
network:
1183
# Displayname template for LinkedIn users.
119-
# {displayname} is replaced with the display name of the LinkedIn user
120-
# as defined below in displayname_preference.
121-
# Keys available for displayname_preference are also available here.
122-
displayname_template: "{displayname} (LinkedIn)"
123-
# Available keys:
124-
# "name" (full name)
125-
# "first_name"
126-
# "last_name"
127-
displayname_preference:
128-
- name
129-
- first_name
130-
131-
# Whether or not to set the topic on DMs to the user's occupation and a
132-
# link to their profile.
133-
set_topic_on_dms: true
134-
135-
# The prefix for commands. Only required in non-management rooms.
136-
command_prefix: "!li"
137-
138-
# Number of chats to sync (and create portals for) on startup/login.
139-
# Set 0 to disable automatic syncing.
140-
initial_chat_sync: 20
141-
# Whether or not the LinkedIn users of logged in Matrix users should be
142-
# invited to private chats when the user sends a message from another client.
143-
invite_own_puppet_to_pm: false
144-
# Whether or not to use /sync to get presence, read receipts and typing notifications
145-
# when double puppeting is enabled
146-
sync_with_custom_puppets: false
147-
# Whether or not to update the m.direct account data event when double puppeting is enabled.
148-
# Note that updating the m.direct event is not atomic (except with mautrix-asmux)
149-
# and is therefore prone to race conditions.
150-
sync_direct_chat_list: false
151-
# Servers to always allow double puppeting from
152-
double_puppet_server_map:
153-
{{ .BeeperDomain }}: {{ .HungryAddress }}
154-
# Allow using double puppeting from any server with a valid client .well-known file.
155-
double_puppet_allow_discovery: false
156-
# Shared secrets for https://github.com/devture/matrix-synapse-shared-secret-auth
157-
#
158-
# If set, custom puppets will be enabled automatically for local users
159-
# instead of users having to find an access token and run `login-matrix`
160-
# manually.
161-
# If using this for other servers than the bridge's server,
162-
# you must also set the URL in the double_puppet_server_map.
163-
login_shared_secret_map:
164-
{{ .BeeperDomain }}: "as_token:{{ .ASToken }}"
165-
# Whether or not to bridge presence in both directions. LinkedIn allows users not to broadcast
166-
# presence, but then it won't send other users' presence to the client.
167-
presence: false
168-
# Whether or not to update avatars when syncing all contacts at startup.
169-
update_avatar_initial_sync: true
170-
# Whether or not created rooms should have federation enabled.
171-
# If false, created portal rooms will never be federated.
172-
federate_rooms: false
173-
# Whether to explicitly set the avatar and room name for private chat portal rooms.
174-
# If set to `default`, this will be enabled in encrypted rooms and disabled in unencrypted rooms.
175-
# If set to `always`, all DM rooms will have explicit names and avatars set.
176-
# If set to `never`, DM rooms will never have names and avatars set.
177-
private_chat_portal_meta: never
178-
179-
# End-to-bridge encryption support options.
180-
#
181-
# See https://docs.mau.fi/bridges/general/end-to-bridge-encryption.html for more info.
182-
encryption:
183-
# Allow encryption, work in group chat rooms with e2ee enabled
184-
allow: true
185-
# Default to encryption, force-enable encryption in all portals the bridge creates
186-
# This will cause the bridge bot to be in private chats for the encryption to work properly.
187-
default: true
188-
# Whether to use MSC2409/MSC3202 instead of /sync long polling for receiving encryption-related data.
189-
appservice: true
190-
# Require encryption, drop any unencrypted messages.
191-
require: true
192-
# Enable key sharing? If enabled, key requests for rooms where users are in will be fulfilled.
193-
# You must use a client that supports requesting keys from other users to use this feature.
194-
allow_key_sharing: true
195-
# Options for deleting megolm sessions from the bridge.
196-
delete_keys:
197-
# Beeper-specific: delete outbound sessions when hungryserv confirms
198-
# that the user has uploaded the key to key backup.
199-
delete_outbound_on_ack: true
200-
# Don't store outbound sessions in the inbound table.
201-
dont_store_outbound: false
202-
# Ratchet megolm sessions forward after decrypting messages.
203-
ratchet_on_decrypt: true
204-
# Delete fully used keys (index >= max_messages) after decrypting messages.
205-
delete_fully_used_on_decrypt: true
206-
# Delete previous megolm sessions from same device when receiving a new one.
207-
delete_prev_on_new_session: true
208-
# Delete megolm sessions received from a device when the device is deleted.
209-
delete_on_device_delete: true
210-
# Periodically delete megolm sessions when 2x max_age has passed since receiving the session.
211-
periodically_delete_expired: true
212-
# Delete inbound megolm sessions that don't have the received_at field used for
213-
# automatic ratcheting and expired session deletion. This is meant as a migration
214-
# to delete old keys prior to the bridge update.
215-
delete_outdated_inbound: true
216-
# What level of device verification should be required from users?
217-
#
218-
# Valid levels:
219-
# unverified - Send keys to all device in the room.
220-
# cross-signed-untrusted - Require valid cross-signing, but trust all cross-signing keys.
221-
# cross-signed-tofu - Require valid cross-signing, trust cross-signing keys on first use (and reject changes).
222-
# cross-signed-verified - Require valid cross-signing, plus a valid user signature from the bridge bot.
223-
# Note that creating user signatures from the bridge bot is not currently possible.
224-
# verified - Require manual per-device verification
225-
# (currently only possible by modifying the `trust` column in the `crypto_device` database table).
226-
verification_levels:
227-
# Minimum level for which the bridge should send keys to when bridging messages from Telegram to Matrix.
228-
receive: cross-signed-tofu
229-
# Minimum level that the bridge should accept for incoming Matrix messages.
230-
send: cross-signed-tofu
231-
# Minimum level that the bridge should require for accepting key requests.
232-
share: cross-signed-tofu
233-
# Options for Megolm room key rotation. These options allow you to
234-
# configure the m.room.encryption event content. See:
235-
# https://spec.matrix.org/v1.3/client-server-api/#mroomencryption for
236-
# more information about that event.
237-
rotation:
238-
# Enable custom Megolm room key rotation settings. Note that these
239-
# settings will only apply to rooms created after this option is
240-
# set.
241-
enable_custom: true
242-
# The maximum number of milliseconds a session should be used
243-
# before changing it. The Matrix spec recommends 604800000 (a week)
244-
# as the default.
245-
milliseconds: 2592000000
246-
# The maximum number of messages that should be sent with a given a
247-
# session before changing it. The Matrix spec recommends 100 as the
248-
# default.
249-
messages: 10000
250-
251-
# Disable rotating keys when a user's devices change?
252-
# You should not enable this option unless you understand all the implications.
253-
disable_device_change_key_rotation: true
254-
255-
# Whether or not the bridge should send a read receipt from the bridge bot when a message has
256-
# been sent to LinkedIn.
257-
delivery_receipts: true
258-
# Whether to allow inviting arbitrary mxids to portal rooms
259-
allow_invites: false
260-
# Settings for backfilling messages from LinkedIn.
261-
backfill:
262-
# Whether or not the LinkedIn users of logged in Matrix users should be
263-
# invited to private chats when backfilling history from LinkedIn. This is
264-
# usually needed to prevent rate limits and to allow timestamp massaging.
265-
invite_own_puppet: false
266-
# Maximum number of messages to backfill initially.
267-
# Set to 0 to disable backfilling when creating portal.
268-
initial_limit: 1
269-
# Maximum number of messages to backfill if messages were missed while
270-
# the bridge was disconnected.
271-
# Set to 0 to disable backfilling missed messages.
272-
missed_limit: 50
273-
# If using double puppeting, should notifications be disabled
274-
# while the initial backfill is in progress?
275-
disable_notifications: true
276-
# If this value is greater than 0, then (on backfill) if the
277-
# conversation's last message was more than this number of hours ago,
278-
# then the conversation will automatically be marked it as read.
279-
unread_hours_threshold: 0
280-
periodic_reconnect:
281-
# Interval in seconds in which to automatically reconnect all users.
282-
# This can be used to automatically mitigate the bug where Linkedin stops sending messages.
283-
# Set to -1 to disable periodic reconnections entirely.
284-
interval: 21600
285-
# What to do in periodic reconnects. Either "refresh" or "reconnect"
286-
mode: refresh
287-
# Should even disconnected users be reconnected?
288-
always: true
289-
# The number of seconds that a disconnection can last without triggering an automatic re-sync
290-
# and missed message backfilling when reconnecting.
291-
# Set to 0 to always re-sync, or -1 to never re-sync automatically.
292-
resync_max_disconnected_time: 5
293-
# Whether or not temporary disconnections should send notices to the notice room.
294-
# If this is false, disconnections will never send messages and connections will only send
295-
# messages if it was disconnected for more than resync_max_disconnected_time seconds.
296-
temporary_disconnect_notices: false
297-
# Whether or not the bridge should try to "refresh" the connection if a normal reconnection
298-
# attempt fails.
299-
refresh_on_reconnection_fail: true
300-
# Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run.
301-
# This field will automatically be changed back to false after it,
302-
# except if the config file is not writable.
303-
resend_bridge_info: false
304-
# When using double puppeting, should muted chats be muted in Matrix?
305-
mute_bridging: true
306-
# Whether or not mute status and tags should only be bridged when the portal room is created.
307-
tag_only_on_create: true
308-
309-
# Permissions for using the bridge.
310-
# Permitted values:
311-
# user - Use the bridge with puppeting.
312-
# admin - Use and administrate the bridge.
313-
# Permitted keys:
314-
# * - All Matrix users
315-
# domain - All users on that homeserver
316-
# mxid - Specific user
317-
permissions:
318-
"{{ .UserID }}": "admin"
319-
320-
# Python logging configuration.
321-
#
322-
# See section 16.7.2 of the Python documentation for more info:
323-
# https://docs.python.org/3.6/library/logging.config.html#configuration-dictionary-schema
324-
logging:
325-
version: 1
326-
formatters:
327-
colored:
328-
(): mautrix.util.logging.color.ColorFormatter
329-
format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s"
330-
normal:
331-
format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s"
332-
handlers:
333-
file:
334-
class: logging.handlers.RotatingFileHandler
335-
formatter: normal
336-
filename: ./logs/beeper-linkedin.log
337-
maxBytes: 10485760
338-
backupCount: 10
339-
console:
340-
class: logging.StreamHandler
341-
formatter: colored
342-
loggers:
343-
mau:
344-
level: DEBUG
345-
paho.mqtt:
346-
level: INFO
347-
aiohttp:
348-
level: INFO
349-
root:
350-
level: DEBUG
351-
handlers: [file, console]
4+
# .FirstName is replaced with the first name
5+
# .LastName is replaced with the last name
6+
# .Organization is replaced with the organization name
7+
displayname_template: {{ `"{{ with .Organization }}{{ . }}{{ else }}{{ .FirstName }} {{ .LastName }}{{ end }}"` }}
8+
9+
sync:
10+
# Number of most recently active dialogs to check when syncing chats.
11+
# Set to 0 to remove limit.
12+
update_limit: 0
13+
# Number of most recently active dialogs to create portals for when syncing
14+
# chats.
15+
# Set to 0 to remove limit.
16+
create_limit: 10
17+
18+
{{ setfield . "CommandPrefix" "!linkedin" -}}
19+
{{ setfield . "DatabaseFileName" "mautrix-linkedin" -}}
20+
{{ setfield . "BridgeTypeName" "LinkedIn" -}}
21+
{{ setfield . "BridgeTypeIcon" "mxc://nevarro.space/cwsWnmeMpWSMZLUNblJHaIvP" -}}
22+
{{ setfield . "DefaultPickleKey" "mautrix.bridge.e2ee" -}}
23+
{{ template "bridgev2.tpl.yaml" . }}

cmd/bbctl/bridgeutil.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ var websocketBridges = map[string]bool{
5252
"meta": true,
5353
"twitter": true,
5454
"bluesky": true,
55+
"linkedin": true,
5556
}
5657

5758
func doOutputFile(ctx *cli.Context, name, data string) error {

0 commit comments

Comments
 (0)