Commit Graph

85 Commits

Author SHA1 Message Date
Jason Frerich
876cf82bad [MM-14725] Inform System Admins when a user who managed bot ac… (#11669)
* Add notification, to sysadmins, when a user is disabled and the user
owns bots.

* If the user doesn't have any bots, there is no need to send a
notifcation to sysadmins

* Remove comment

* Update documention link

* Send as System

* Query teams for each sysadmin and add first response to hardcoded link.

* Remove fmt.print debug statements

* remove link with hard-coded team.  Will add this as future enhancement
Expose GetDisableBotSysadminMessage function so it can be tested
Add test new function for testing new notification feature

* Fix shadow error

* Swap sentences in the message when  System Console > Bot Accounts > Disable bot accounts when owner is deactivated: is set to false

* Another message correction

* Rename Custom Integrations to Integrations

* rename botsDisabled variable to disableBotsSetting

* - increase the number of bots and sysadmins queried to 1000.
- limit the number of bots printed in the post to 10, but mention the
  total bots owned by the user

* Enable translations for sysadmin messages

* - Rename function. The actual purpose for the function is to notify
  sysadmins that a user, that owned bots, was disabled.
- convert GetDisableBotSysadminMessage from a function to a method.
  This allows getting *a.Config().ServiceSettings.DisableBotsWhenOwnerIsDeactivated
  in the method and avoids having to pass the value as an input to a
  function

* fix "make i18n-extract" error.  Reorganize .json file

* Correct the upper range value to be the minimum of number of elements in the
userBots array, or the upper limit (10)

* replace t.fatal with require statements
fix golangci-lint errors

* Create separate message when user managed less than or fewer than 10 bots
Test cases for both message types

* fix i18n sorting

* Using pagination to get the bots and sysadmins instead of setting
arbitrary value for PerPage and only retrieving first page

* only use one translation ID for the message.
push all logic into the template so translators can view the logic
add disableBotsSetting and printAllBots variables to the translation
map

* Break the for loop once len(bots) < perPage value, instead of
breaking once there are no bots. This saves one additional call
2019-12-06 20:00:47 -06:00
Harrison Healey
4a23d4b282 MM-20681 Fix custom post types not marking channel unread when using Mark as Unread (#13247)
* MM-20681 Fix custom post types not marking channel unread when using Mark as Unread

* Fix inverted if statements
2019-12-03 14:51:50 -05:00
Jesús Espino
a63684fcb5 Consistent license message for all the go files (#13235)
* Consistent license message for all the go files

* Fixing the last set of unconsistencies with the license headers

* Addressing PR review comments

* Fixing busy.go and busy_test.go license header
2019-11-29 12:59:40 +01:00
Miguel de la Cruz
2259b7f2a8 [MM-19948] Set version on module file and internal paths (#13186)
* [MM-19948] Set version on module file and internal paths

* Fixes after merge

* Fix i18n checker error
2019-11-28 14:39:38 +01:00
Eli Yukelzon
b3517eaf2f MM-17468 - Improving performance of fetching threads (#11980)
fetchThreads parameter support in the API
2019-09-17 14:37:10 +01:00
Miguel de la Cruz
b8fa36cb41 [MM-17200] Adds specific messages when guest is added or joins a channel (#11803)
* [MM-17200] Add user joined as guest message

* [MM-17200] Add user added to channel as guest messages
2019-08-26 12:02:45 +02:00
krjn
dd30488a09 [MM-16389] Add icon_emoji parameter to webhooks (#11586)
[MM-16389] Add icon_emoji field to posts from incoming webhooks

To be used to substitute the profile picture on posts.
2019-07-17 11:01:18 +02:00
jfrerich
95652da0b8 [MM-14720] Add Posts Per Day Analytics and Number Posts Previous Day Functionality (#11402)
* Add ability to get bot counts per day

Modify tests using AnalyticsPostCountsByDay to include extra input
(botsOnly)

Correctly generate the mock file with 'make store-mocks' target.  Didn't
see these comments earlier

* Initial commit for calculating total posts previous day and total posts
from bots previous day

* - Refactor to use asserts instead of if statements in tests
- Capture inputs to AnalyticsPostCountsByDay() function into an
  options struct
- Remove bot creation from diagnostics_test.go.

* Remove utils library

* create AnalyticsPostCountsOptions struct which is accepted as an input
to AnalyticsPostCountsByDay method

* Go vet fixes
2019-07-02 14:10:22 -07:00
Donald Feury
66993e1fae MM-2954 - Add a separate post type for /me messages and update formatting (#11082)
* MM-2954

* Added new const post type for /me commands
* Modified me command to return response text without *__* wrapper
* Modified unit test for MeCommand to reflect changes
* Added unit test for the me command provider

* * Reverted change to text property in me command response
* Added original message in me command response props
* Updated unit tests

* gofmt changes
2019-06-20 17:16:36 -04:00
Devin Binnie
c524ee544f [MM-14727] Modified App.Bot.CreateBot to create a new post to the bot… (#11062) 2019-06-13 13:36:13 +02:00
Daniel Schalla
7c9837d9b1 [MM-14846] Update EditAt for FileIds and Attachment in Post + Ignore FileIds Updates (#10540)
* Set EditAt for FileIds and Attachments; Disallow update/patch of FileIds in API Handler

* Add custom comparison methods for StringArray and Post Attachments

* gofmt

* Split up comparison function to child structs

* Naming consistency

* gofmt
2019-04-04 20:01:21 +02:00
Fernando Correa Neto
9abd4dd7dc [MM 12464] Include DM/GM Channels and Their Posts in the Bulk Export (#10421)
* transplant the existing PR into the working tree

* start addressing review comments

* move existing direct channel export code into this branch

* modify channel exporter to use squirell and populate members in two steps

* use squirrel to build sql queries for channel and dm/gm export methods

* remove debug helpers and use Username instead of UserId

* unit test for DM Channel exporter

* add more unit tests for channel export

* add test for DM/GM post export

* checkpoint with failing test for postgres

* use getQueryBuilder to make sure squirrel uses the correct formatting
for each database

* add a test for post export

* fix shadowed vars that broke the build

* address review comments and add tests to support it

* address review comments and add a mlog call

* s/Info/Debug/

* address review comments in post_store

* address review comments in channel_store

* address review comments in export

* address review comment in post_store: drop GroupBy

* address review comment on supplier: move getQueryBuilder to sqlstore

* address review comments: explicit TearDown

* address review comments: improve test coverage

* address review comments: make sure public and private channels are excluded

* address review comments: improve test coverage

* address review comments: make sure Channels table gets truncated after
each test

* more cleanups and better assertions

* wrap PostStore in a StoreTestWithSqlSupplier

* last minute changes: improve post export test coverage and check members

* address review comments: make sure all posts have their channel
members set

* address review comments: make sure all posts have their ChannelMembers
exported correctly

* gofmt fix

* sort channels so it's possible to assert on index
2019-03-15 16:28:43 +01:00
Harrison Healey
6325c5b569 MM-13718 Prevent files from being attached to multiple posts (#10094)
* MM-13718 Prevent files from being attached to multiple posts

* Switch back to non-batched AttachToPost

* Change status code when failing to attach a file
2019-01-22 12:58:22 -08:00
Harrison Healey
385a0048bf MM-13015 Remove metadata field from post when metadata is disabled (#9882) 2018-11-26 10:48:58 -05:00
Harrison Healey
5f65356a3f Address issues 2018-11-22 13:10:36 -05:00
Harrison Healey
5388afd37e Remove comments about deprecating FileIds and HasReactions (#9869) 2018-11-22 13:09:27 -05:00
Harrison Healey
8dc865b917 Merge branch 'master' into post-metadata 2018-11-19 16:51:56 -05:00
Joram Wilander
8cfca681b0 MM-12843 Add interactive dialogs (#9816)
* Add interactive dialogs

* Fix unit test

* Updates per feedback

* Fix typo

* Updates per feedback, add icon_url and error returns

* Updates per feedback

* Update per feedback
2018-11-19 15:27:17 -05:00
Harrison Healey
18684dd6de MM-11868/MM-12010/MM-12011/MM-12036 Improve post metadata structure (#9693)
* MM-11868/MM-12010/MM-12011/MM-12036 Include dimensions for opengraph and message attachment images in post metadata

* Remove duplicate check from getFirstLinkAndImages

* Add tests for getImagesInMessageAttachments

* Rename PostMetadata.FileInfos to PostMetadata.Files

* Rename Metadata.ImageDimensions to Metadata.Images
2018-11-01 15:41:29 -04:00
Harrison Healey
2959b53d98 MM-11272 Add OpenGraph and image dimension metadata to posts (#9313)
* Move OpenGraph code into its own file

* Move OpenGraph image proxying to app layer

* Move test file code out of api4 package

* MM-11272 Add OpenGraph and image dimension metadata to posts
2018-11-01 15:25:11 -04:00
Harrison Healey
48f16b6401 MM-11272 Added initial post metadata (#9175)
* MM-11272 Added app.PreparePostForClient

* MM-11272 Added app.PreparePostListForClient

* MM-11272 Added EmojiStore.GetMultipleByName

* MM-11272 Added emojis to PreparePostForClient

* MM-11272 Added unit tests for getting reaction counts

* MM-11272 Added unit tests for TestPreparePostForClient

* MM-11272 Added emojis from reactions to Post.Emojis

* MM-11272 Always update post.UpdateAt when reactions change to bust cache

* Fixed merge conflicts

* Moved post metadata-related code into its own file

* Update store mocks

* Fixed typo

* Add missing license headers

* Updated post metadata tests when custom emojis are disabled

* Fix unreliable unit tests

* Fix inconsistent casing in SQL statements

* Fix blank line

* Invalidate store cache after making changes

* Clear post cache synchronously with reactions
2018-11-01 15:22:33 -04:00
Christopher Speller
37e00ef916 Adding paging to elasticsearch API. (#9425) 2018-09-26 10:27:04 -04:00
Hanzei
1463df21a5 Add ChannelId and TeamId to PostActionIntegrationRequest (#9384)
* Add ChannelId and TeamId to PostActionIntegrationRequest

* Add tests
2018-09-19 08:39:36 -04:00
George Goldberg
ab99f0656f MM-11781: Basic Data Export Command Line. (#9296)
* MM-11781: Basic Data Export Command Line.

* ChannelStore new unit tests.

* TeamStore new unit tests.

* Unit test for new UserStore function.

* Unit tests for post store new methods.

* Review fixes.

* Fix duplicate command name.
2018-09-17 15:51:26 +01:00
Dmitry Samuylov
42806ae965 Feature/search after before on (#9219)
* initial implementation of after, before, on search flags allowing to restrict the search to a specific day or a date range

* missed setting beforeDate in SearchParams in one place

* fixed condition when only flags are used for search without any plain terms

* changed date format used for after/before/on flags to be in ISO8601 format as suggested in PR comments, added a helper function to pad month and day with zeroes allowing the user user either format, with or without leading zeroes

* corrected expected compare to date setting for the TestParseDateFilterToTimeISO8601 test

* fixed a bug for the scenario when you only have the date flags without any terms, added a couple of tests for that scenario

* updated the date filter logic to use parameters to construct the query instead of simply appending strings together, as suggested in the pull request comments

* added search unit test using date flags

* added a helper function to create a test post with a createat date manually set, updated the test for search using date flags to create test posts with different createat dates to be able to better test the functionality

* MM-11817 Add support for after/before/on search flags with Elasticsearch

* add support to search posts to perform the search in context of the client's timezone when filtering by createat date using on: after: before: flags

* updated tests to match the new signature
2018-08-28 13:09:32 -04:00
Joram Wilander
4de2e5206e Support for interactive menus in message attachments (#9285) 2018-08-24 11:16:17 +01:00
Hanzei
56d92de3f2 Add ToJson() to PostActionIntegrationResponse (#9247)
* Add ToJson() to PostActionIntegrationResponse

This commits adds a ToJson() methode to PostActionIntegrationResponse.

It also adds tests for other ToJson() methods

* Add PostActionIntegrationResponseFromJson function

* Add PostActionIntegrationRequesteFromJson() function

* Fix test names

* Add testcase
2018-08-20 09:21:16 -07:00
Hanzei
c2f2fda8a1 Add PostId to PostActionIntegrationRequest (#9270) 2018-08-18 08:35:32 -04:00
Jesse Hallam
2d7cd02abc MM-10833: send down computed channel props (#8953)
* MM-10833: send down computed channel props

This allows channel headers to reference channel mentions for a client
that doesn't already know about the channels in question.

We intentionally don't send down the props for the autocomplete and
search endpoints since they aren't used in that context, and would add
unnecessary overhead.

* update channel props on patch

* revert to treating channel purpose as plaintext
2018-06-26 16:46:57 -04:00
Martin Kraft
260d7a0f85 MM-10412: Adds deleteBy prop to posts. (#8896) 2018-06-01 12:45:46 -04:00
Martin Kraft
4921fda79f MM-10122: Adds a mention for added-to-channel messages even when 'username mentions' are disabled. (#8648) 2018-04-19 11:28:04 +01:00
Daniel Schalla
997df03ac1 Initial Commit of Ephemeral Message Support for System Admins (#8611)
Fixed Permission Test

Fixed and extended ephemeral message tests; Removed Online/Activity Updates

Set Create Time to current time

gofmt
2018-04-17 08:20:47 -04:00
Stan Chan
7826774a14 Add Auto Responder handler (#8386)
WIP Out Of Office

Return error for status command if user status is OOO

Ignore notifications if Out Of Office

Disable AutoResponder if status is set to online

Add test for AutoResponder

DisableAutoResponse when manually setting status

Remove check on status slash command

return early if user does not exists in SendAutoResponse method

Add proper error handling

Add a newline after error handling

Revert back to err == nil in api4/status.go

Remove a.Go when using a.Publish

Add name consistency with the feature auto responder

Last changes for name consistency, also fix failing test with auto_responder

Fix names of functions in auto responder test

Add ExperimentalEnableAutomaticReplies flag

Auto Responder reply to a post
2018-04-12 15:02:36 -04:00
Saturnino Abril
07b14c370a post a system message after a channel is converted from public to private (#8501) 2018-03-27 21:14:42 +08:00
Jesse Hallam
8491ba5740 Relax 4k post message limit (#8478)
* MM-9661: rename POST_MESSAGE_MAX_RUNES to \0_v1

* MM-9661: s/4000/POST_MESSAGE_MAX_RUNES_V1/ in tests

* MM-9661: introduce POST_MESSAGE_MAX_RUNES_V2

* MM-9661: migrate Postgres Posts.Message column to TEXT from VARCHAR(4000)

This is safe to do in a production instance since the underyling type is
not changing. We explicitly don't do this automatically for MySQL, but
also don't need to since the ORM would have already created a TEXT column
for MySQL in that case.

* MM-9661: emit MaxPostSize in client config

This value remains unconfigurable at this time, but exposes the current
limit to the client. The limit remains at 4k in this commit.

* MM-9661: introduce and use SqlPostStore.GetMaxPostSize

Enforce a byte limitation in the database, and use 1/4 of that value as
the rune count limitation (assuming a worst case UTF-8 representation).

* move maxPostSizeCached, lastPostsCache and lastPostTimeCache out of the global context and onto the SqlPostStore

* address feedback from code review:

* ensure sqlstore unit tests are actually being run
* move global caches into SqlPostStore
* leverage sync.Once to address a race condition

* modify upgrade semantics to match new db semantics

gorp's behaviour on creating columns with a maximum length on Postgres
differs from MySQL:
* Postgres
  * gorp uses TEXT for string columns without a maximum length
  * gorp uses VARCHAR(N) for string columns with a maximum length of N
* MySQL
  * gorp uses TEXT for string columns with a maximum length >= 256
  * gorp uses VARCHAR(N) for string columns with a maximum length of N
  * gorp defaults to a maximum length of 255, implying VARCHAR(255)

So the Message column has been TEXT on MySQL but VARCHAR(4000) on
Postgres. With the new, longer limits of 65535, and without changes to
gorp, the expected behaviour is TEXT on MySQL and VARCHAR(65535) on
Postgres. This commit makes the upgrade semantics match the new database
semantics.

Ideally, we'd revisit the gorp behaviour at a later time.

* allow TestMaxPostSize test cases to actually run in parallel

* default maxPostSizeCached to POST_MESSAGE_MAX_RUNES_V1 in case the once initializer panics

* fix casting error

* MM-9661: skip the schema migration for Postgres

It turns out resizing VARCHAR requires a rewrite in some versions of
Postgres, but migrating VARCHAR to TEXT does not. Given the increasing
complexity, let's defer the migration to the enduser instead.
2018-03-26 17:55:35 -04:00
Chris
cf929476bd fix client4 post sanitization (#8219) 2018-02-08 11:54:45 -05:00
Vordimous
7bd298ceaa PLT-7537: Move channel CLI command posts system message to channel. (#8161)
* [PTL-7537] implement feature and test

* [PTL-7537] Update feature to post the the room requiring a username flag to be used

* [PTL-7537] update tests with username

* update test to remove changes to the test helper struct

* use the basic team and user
2018-02-07 14:17:18 +00:00
Chris
0c8968fb8d unnamed return (#8170) 2018-01-30 15:23:00 -08:00
Harrison Healey
195ad56204 Merge branch 'release-4.6' 2018-01-23 15:07:31 -05:00
Chris
599991ea73 PLT-3383: image proxy support (#7991)
* image proxy support

* go vet fix, remove mistakenly added coverage file

* fix test compile error

* add validation to config settings and documentation to model functions

* add message_source field to post
2018-01-22 15:32:50 -06:00
Evgeniy
9d6a9ff4be Post a system message to the affected channel by CLI command (#7877) (#7968) 2018-01-18 16:05:00 -05:00
Harrison Healey
90abd76d3f PLT-8522 Added separate messages for being removed from channel or team (#8078) 2018-01-10 12:22:51 -07:00
Tsilavina Razafinirina
0cdf969ac7 PLT-6217-bis Fixes system message posted to Town Square when a user joins a team #7863 (#7864)
* Adds new string post message when a user has joined a team (#6483)

* Simplifies long if statement in post.go (#6483)
2017-12-08 11:15:33 -08:00
Chris
b87fae646a PLT-5458: If someone posts a channel link to channel_A that you don't belong to, it doesn't render properly (#7833)
* add channel link hints to post props

* optimization

* update regex, add unit test

* fix rebase issue
2017-11-28 13:02:56 -08:00
Tsilavina Razafinirina
ab6ef954b4 PLT-6217 Fixes system message posted to Town Square when a member leaves a team (#7752)
* Fixes system message posted to Town Square when adding/removing team member (#6483)

Fixes unit test method call to match RemoveUserFromTeam modification (#6483)

Fixes system message posted to Town Square when adding/removing team member (#6483)

Removes unnessary error message

* Updates system message when a user leaves a team (#6483)

* Changes system message when a user is removed from team (#6483)

* Adds a new string to be post to town-square when a member is added to a team (#6483)
2017-11-20 10:15:33 -05:00
Chris
9c0575ce6e PLT-7599: webhook post splitting (#7707)
* webhook post splitting

* style fix

* update old webhook test
2017-10-24 19:36:31 -04:00
Saturnino Abril
18ee375860 [PLT-7362] Option to add user to channel if mentioned user is not currently in the channel (#7619)
* Option to add user to channel if mentioned user is not currently in the channel

* instead of link from server, just add component on client side to add channel member

* change implementation using post.props

* do clean up and add test

* sanitize post.props['add_channel_member'] on post creation

* move sanitize to app.CreatePost and also apply to app.UpdatePost
2017-10-21 01:38:26 +08:00
Joram Wilander
1bd66589a2 Allow custom post types (#7468) 2017-09-27 11:09:09 -04:00
Chris
e7e10d36a9 interactive post update fix (#7477) 2017-09-19 17:05:20 -04:00
George Goldberg
2be5577b88 Model: NewLocAppError -> NewAppError (#7450) 2017-09-15 08:32:11 -04:00